Skip to content

fix: better comment suggestion - #2421

Open
HsienChing wants to merge 1 commit into
tensorflow:masterfrom
HsienChing:patch-2
Open

HsienChing wants to merge 1 commit into
tensorflow:masterfrom
HsienChing:patch-2

Conversation

@HsienChing

Copy link
Copy Markdown

Better comment suggestion

Position: "Gradient tapes" section

Condition:
It's better to use "# dy/dx = 2x" instead of "# dy = 2x * dx" in the comment.

I know that the "dy/dx = 2x" and "dy = 2x * dx" are equivalent.

As this is the first time I see the comment "# dy = 2x * dx" and the following code "dy_dx = tape.gradient(y, x)", I don't get the meaning immediately.

When I changed the comment to "# dy/dx = 2x", which is much closer to the code "dy_dx = tape.gradient(y, x)". And I can obviously understand the code.

Suggestion: Use "# dy/dx = 2x" instead of "# dy = 2x * dx" in the comment.

The same thing happened again in the "Controlling what the tape watches" section.

REF: https://github.com/HsienChing/ML_DL_project_State_Estimation_of_Li-ion_Batteries/blob/main/other/Issues_in_TensorFlow_official_doc_Introduction_to_gradients_and_automatic_differentiation.ipynb

# Better comment suggestion 

**Position:** "Gradient tapes" section

**Condition:**
It's better to use "`# dy/dx = 2x`" instead of "`# dy = 2x * dx`" in the comment.

I know that the "dy/dx = 2x" and "dy = 2x * dx" are equivalent. 

As this is the first time I see the comment "`# dy = 2x * dx`" and the following code "`dy_dx = tape.gradient(y, x)`", I don't get the meaning immediately. 

When I changed the comment to "`# dy/dx = 2x`", which is much closer to the code "`dy_dx = tape.gradient(y, x)`". And I can obviously understand the code.

**Suggestion:** Use "`# dy/dx = 2x`" instead of "`# dy = 2x * dx`" in the comment.

The same thing happened again in the "Controlling what the tape watches" section.

REF: https://github.com/HsienChing/ML_DL_project_State_Estimation_of_Li-ion_Batteries/blob/main/other/Issues_in_TensorFlow_official_doc_Introduction_to_gradients_and_automatic_differentiation.ipynb
@HsienChing
HsienChing requested a review from a team as a code owner April 8, 2026 09:24
@github-actions

github-actions Bot commented Apr 8, 2026

Copy link
Copy Markdown

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 patch-2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant