Commit 03706c5
Modernize Neural Networks tutorial patterns (#3881)
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
- [x] The issue that is being fixed is referred in the description (see
above "Fixes #ISSUE_NUMBER")
- [x] Only one issue is addressed in this pull request
- [x] Labels from the issue that this PR is fixing are added to this
pull request
- [x] No unnecessary issues are included into this pull request.
Co-authored-by: sekyondaMeta <127536312+sekyondaMeta@users.noreply.github.com>1 parent a06493e commit 03706c5
1 file changed
Lines changed: 7 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
208 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
209 | 211 | | |
210 | 212 | | |
211 | 213 | | |
| |||
246 | 248 | | |
247 | 249 | | |
248 | 250 | | |
249 | | - | |
| 251 | + | |
| 252 | + | |
250 | 253 | | |
251 | 254 | | |
252 | 255 | | |
| |||
0 commit comments