Merge pull request #229 from ibeauregard/changes-chap4

Remove useless code
main
Aurélien Geron 2021-03-02 17:27:54 +13:00 committed by GitHub
commit 4963911f4f
1 changed files with 0 additions and 3 deletions

View File

@ -1653,9 +1653,6 @@
"for iteration in range(n_iterations):\n", "for iteration in range(n_iterations):\n",
" logits = X_train.dot(Theta)\n", " logits = X_train.dot(Theta)\n",
" Y_proba = softmax(logits)\n", " Y_proba = softmax(logits)\n",
" xentropy_loss = -np.mean(np.sum(Y_train_one_hot * np.log(Y_proba + epsilon), axis=1))\n",
" l2_loss = 1/2 * np.sum(np.square(Theta[1:]))\n",
" loss = xentropy_loss + alpha * l2_loss\n",
" error = Y_proba - Y_train_one_hot\n", " error = Y_proba - Y_train_one_hot\n",
" gradients = 1/m * X_train.T.dot(error) + np.r_[np.zeros([1, n_outputs]), alpha * Theta[1:]]\n", " gradients = 1/m * X_train.T.dot(error) + np.r_[np.zeros([1, n_outputs]), alpha * Theta[1:]]\n",
" Theta = Theta - eta * gradients\n", " Theta = Theta - eta * gradients\n",