docs icon indicating copy to clipboard operation
docs copied to clipboard

Fix: use add_weight instead of tf.Variable in training loop guide

Open Aaraviitkgp opened this issue 5 months ago • 11 comments

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. Screenshot 2025-07-26 at 4 07 27 PM

Aaraviitkgp avatar Jul 26 '25 10:07 Aaraviitkgp

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.

google-cla[bot] avatar Jul 26 '25 10:07 google-cla[bot]

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/docs

$ python3 -m tensorflow_docs.tools.nbfmt notebook.ipynb
$ python3 -m tensorflow_docs.tools.nblint --arg=repo:tensorflow/docs notebook.ipynb
If commits are added to the pull request, synchronize your local branch: git pull origin fix-trainable-warning-doc

github-actions[bot] avatar Jul 26 '25 10:07 github-actions[bot]

@googlebot I signed it!

Aaraviitkgp avatar Jul 26 '25 10:07 Aaraviitkgp

Hi, thanks for creating the PR, but this doesn't work in Colab, please fix.

MarkDaoust avatar Jul 28 '25 16:07 MarkDaoust

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/docs

$ python3 -m tensorflow_docs.tools.nbfmt notebook.ipynb
$ python3 -m tensorflow_docs.tools.nblint --arg=repo:tensorflow/docs notebook.ipynb
If commits are added to the pull request, synchronize your local branch: git pull origin fix-trainable-warning-doc

github-actions[bot] avatar Jul 28 '25 16:07 github-actions[bot]

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: @.***>

Aaraviitkgp avatar Jul 28 '25 16:07 Aaraviitkgp

I have made changes please check

Aaraviitkgp avatar Jul 28 '25 18:07 Aaraviitkgp

@MarkDaoust Hello there, I have made the changes please check

Aaraviitkgp avatar Jul 30 '25 14:07 Aaraviitkgp

@MarkDaoust please review

Aaraviitkgp avatar Aug 08 '25 04:08 Aaraviitkgp

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 avatar Aug 08 '25 15:08 MarkDaoust

@MarkDaoust please check if its ok.

Aaraviitkgp avatar Aug 08 '25 17:08 Aaraviitkgp