Fix: use add_weight instead of tf.Variable in training loop guide
Fixes [tensorflow/tensorflow#97599]
(https://github.com/tensorflow/tensorflow/issues/97599).
Replaced tf.Variable(...) with add_weight(...) in the custom model to avoid training warning and ensure proper Keras weight tracking.
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
View this failed invocation of the CLA check for more information.
For the most up to date status, view the checks section at the bottom of the pull request.
Preview
Preview and run these notebook edits with Google Colab: Rendered notebook diffs available on ReviewNB.com.Format and style
Use the TensorFlow docs notebook tools to format for consistent source diffs and lint for style:$ python3 -m pip install -U --user git+https://github.com/tensorflow/docsIf commits are added to the pull request, synchronize your local branch:
$ python3 -m tensorflow_docs.tools.nbfmt notebook.ipynb
$ python3 -m tensorflow_docs.tools.nblint --arg=repo:tensorflow/docs notebook.ipynb
git pull origin fix-trainable-warning-doc
@googlebot I signed it!
Hi, thanks for creating the PR, but this doesn't work in Colab, please fix.
Preview
Preview and run these notebook edits with Google Colab: Rendered notebook diffs available on ReviewNB.com.Format and style
Use the TensorFlow docs notebook tools to format for consistent source diffs and lint for style:$ python3 -m pip install -U --user git+https://github.com/tensorflow/docsIf commits are added to the pull request, synchronize your local branch:
$ python3 -m tensorflow_docs.tools.nbfmt notebook.ipynb
$ python3 -m tensorflow_docs.tools.nblint --arg=repo:tensorflow/docs notebook.ipynb
git pull origin fix-trainable-warning-doc
Hello there Mark, I checked it on Colab and it seems to work fine for me. I have attached screenshots of the code working fine for me, if any error please let me know. Thankyou
On Mon, Jul 28, 2025 at 9:30 PM Mark Daoust @.***> wrote:
MarkDaoust left a comment (tensorflow/docs#2388) https://github.com/tensorflow/docs/pull/2388#issuecomment-3127920437
Hi, thanks for creating the PR, but this doesn't work in Colab, please fix.
— Reply to this email directly, view it on GitHub https://github.com/tensorflow/docs/pull/2388#issuecomment-3127920437, or unsubscribe https://github.com/notifications/unsubscribe-auth/BOXUPB75CEQQ5ICANUU7QQD3KZCJZAVCNFSM6AAAAACCNNWMASVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTCMRXHEZDANBTG4 . You are receiving this because you authored the thread.Message ID: @.***>
I have made changes please check
@MarkDaoust Hello there, I have made the changes please check
@MarkDaoust please review
It's hard to review this with all the whitespace changes. Please follow the comment above to reformat:
Use the TensorFlow docs notebook tools to format for consistent source diffs and lint for style:
@MarkDaoust please check if its ok.