Skip to content

Commit

Permalink
solved grad descent problem
Browse files Browse the repository at this point in the history
  • Loading branch information
LordSomen committed Aug 23, 2018
1 parent df47694 commit 324f01b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Tensorflow/tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,18 @@
theta_value = theta.eval()
print(theta_value)

#%%
'''scaling the data for gradient descent'''
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
scaled_housing_data = scaler.fit_transform(housing.data)
scaled_housing_data_with_bias = np.c_[np.ones((m,1)),scaled_housing_data]
print(scaled_housing_data_with_bias)

#%%
n_epochs = 1000
learning_rate = 0.01
X = tf.constant(housing_data_plus_bias, dtype=tf.float32, name="X")
X = tf.constant(scaled_housing_data_with_bias, dtype=tf.float32, name="X")
y = tf.constant(housing.target.reshape(-1, 1), dtype=tf.float32, name="y")
theta = tf.Variable(tf.random_uniform([n + 1, 1], -1.0, 1.0), name="theta")
y_pred = tf.matmul(X, theta, name="predictions")
Expand Down

0 comments on commit 324f01b

Please sign in to comment.