Skip to content Skip to sidebar Skip to footer

Tensorflow On Simple Linear Regression

I am a beginner in machine learning and tensorflow. In the first step trying the tensorflow, I tried a simple multivariate linear regression. However, it seems the model stuck at a

Solution 1:

This is because y is not the same shape as y_. y is of shape (1000, 1) and y_ is of shape (1000). So when you subtract them, you're inadvertently creating a 2-D matrix.

To fix it change your cost function to:

cost_function = tf.reduce_mean(tf.square(tf.squeeze(y) - y_))

Solution 2:

As mentioned in another answer, u have to use

predictions = tf.add(b, tf.matmul(x, w))
error = tf.reduce_mean(tf.square(y - predictions))

And as you are saying that, you are a Tensorflow beginner, you can look at the example here:-

https://medium.com/@saxenarohan97/intro-to-tensorflow-solving-a-simple-regression-problem-e87b42fd4845

Post a Comment for "Tensorflow On Simple Linear Regression"