Skip to content

Modernize Neural Networks tutorial patterns#3881

Open
ymrohit wants to merge 1 commit intopytorch:mainfrom
ymrohit:docathon-3877-modernize-neural-networks
Open

Modernize Neural Networks tutorial patterns#3881
ymrohit wants to merge 1 commit intopytorch:mainfrom
ymrohit:docathon-3877-modernize-neural-networks

Conversation

@ymrohit
Copy link
Copy Markdown

@ymrohit ymrohit commented May 8, 2026

Fixes #3877

Description

Modernizes the Neural Networks tutorial by updating the old-style super() call, replacing the commented .data parameter update with a torch.no_grad() update, and clarifying why net.zero_grad() is still used before the optimizer section introduces optimizer.zero_grad().

Testing

  • git diff --check origin/main..HEAD
  • python -m py_compile beginner_source/blitz/neural_networks_tutorial.py
  • python beginner_source/blitz/neural_networks_tutorial.py

Checklist

  • The issue that is being fixed is referred in the description (see above "Fixes #ISSUE_NUMBER")
  • Only one issue is addressed in this pull request
  • Labels from the issue that this PR is fixing are added to this pull request
  • No unnecessary issues are included into this pull request.

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 8, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/tutorials/3881

Note: Links to docs will display an error until the docs builds have been completed.

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the cla signed label May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update Neural Networks tutorial — modernize super(), zero_grad, and .data usage

1 participant