From 14723abc07243143d1906c1686abe2578ea2ed95 Mon Sep 17 00:00:00 2001 From: RoomWithOutRoof Date: Sun, 19 Apr 2026 19:23:35 +0800 Subject: [PATCH] Fix 3 documentation issues in basic_training_loops guide MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Fixed incorrect color description (cell 17): 'predictions in red and the training data in blue' → 'predictions and the training data' (No explicit colors are set in the plotting code) 2. Improved gradient variable naming for clarity (cell 20): dw, db → grad_w, grad_b (Avoids confusion with weight/bias variables) 3. Fixed Keras save_weights filename bug (cell 30): 'my_checkpoint' → 'my_checkpoint.weights.h5' (Keras requires .weights.h5 extension) Reported via: https://github.com/tensorflow/tensorflow/issues/116299 --- site/en/guide/basic_training_loops.ipynb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/site/en/guide/basic_training_loops.ipynb b/site/en/guide/basic_training_loops.ipynb index a1558b1903e..b6c6fa80908 100644 --- a/site/en/guide/basic_training_loops.ipynb +++ b/site/en/guide/basic_training_loops.ipynb @@ -266,7 +266,7 @@ "id": "-50nq-wPBsAW" }, "source": [ - "Before training the model, you can visualize the loss value by plotting the model's predictions in red and the training data in blue:" + "Before training the model, you can visualize the loss value by plotting the model's predictions and the training data:" ] }, { @@ -322,11 +322,11 @@ " current_loss = loss(y, model(x))\n", "\n", " # Use GradientTape to calculate the gradients with respect to W and b\n", - " dw, db = t.gradient(current_loss, [model.w, model.b])\n", + " grad_w, grad_b = t.gradient(current_loss, [model.w, model.b])\n", "\n", " # Subtract the gradient scaled by the learning rate\n", - " model.w.assign_sub(learning_rate * dw)\n", - " model.b.assign_sub(learning_rate * db)" + " model.w.assign_sub(learning_rate * grad_w)\n", + " model.b.assign_sub(learning_rate * grad_b)" ] }, { @@ -491,7 +491,7 @@ "training_loop(keras_model, x, y)\n", "\n", "# You can also save a checkpoint using Keras's built-in support\n", - "keras_model.save_weights(\"my_checkpoint\")" + "keras_model.save_weights(\"my_checkpoint.weights.h5\")" ] }, { @@ -595,4 +595,4 @@ }, "nbformat": 4, "nbformat_minor": 0 -} +} \ No newline at end of file