Skip to content

Commit e445c53

Browse files
authored
Merge pull request #42 from MisaOgura/2-26_gradient-descent
fix: gradient descent
2 parents 7d4e0d3 + 3a56f48 commit e445c53

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

intro-neural-networks/gradient-descent/GradientDescent.ipynb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@
141141
" for e in range(epochs):\n",
142142
" del_w = np.zeros(weights.shape)\n",
143143
" for x, y in zip(features, targets):\n",
144-
" output = output_formula(x, weights, bias)\n",
145-
" error = error_formula(y, output)\n",
146144
" weights, bias = update_weights(x, y, weights, bias, learnrate)\n",
147145
" \n",
148146
" # Printing out the log-loss error on the training set\n",
@@ -156,7 +154,11 @@
156154
" else:\n",
157155
" print(\"Train loss: \", loss)\n",
158156
" last_loss = loss\n",
157+
" \n",
158+
" # Converting the output (float) to boolean as it is a binary classification\n",
159+
" # e.g. 0.95 --> True (= 1), 0.31 --> False (= 0)\n",
159160
" predictions = out > 0.5\n",
161+
" \n",
160162
" accuracy = np.mean(predictions == targets)\n",
161163
" print(\"Accuracy: \", accuracy)\n",
162164
" if graph_lines and e % (epochs / 100) == 0:\n",

0 commit comments

Comments
 (0)