Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions tensorflow_v2/notebooks/2_BasicModels/linear_regression.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@
"X = np.array([3.3,4.4,5.5,6.71,6.93,4.168,9.779,6.182,7.59,2.167,\n",
" 7.042,10.791,5.313,7.997,5.654,9.27,3.1])\n",
"Y = np.array([1.7,2.76,2.09,3.19,1.694,1.573,3.366,2.596,2.53,1.221,\n",
" 2.827,3.465,1.65,2.904,2.42,2.94,1.3])\n",
"n_samples = X.shape[0]"
" 2.827,3.465,1.65,2.904,2.42,2.94,1.3])\n"
]
},
{
Expand All @@ -76,7 +75,7 @@
"\n",
"# Mean square error.\n",
"def mean_square(y_pred, y_true):\n",
" return tf.reduce_sum(tf.pow(y_pred-y_true, 2)) / (2 * n_samples)\n",
" return tf.reduce_mean(tf.square(y_pred - y_true))\n",
"\n",
"# Stochastic Gradient Descent Optimizer.\n",
"optimizer = tf.optimizers.SGD(learning_rate)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
" # Set forward pass.\n",
" def call(self, x, is_training=False):\n",
" x = self.fc1(x)\n",
" x = self.fc2(x)\n"
" x = self.fc2(x)\n",
" x = self.out(x)\n",
" if not is_training:\n",
" # tf cross entropy expect logits without softmax, so only\n",
Expand Down