Last active
January 6, 2019 12:34
-
-
Save vaibkumr/919e2292382bbda0b8c077fa122e6c7a to your computer and use it in GitHub Desktop.
Check if tracking is enabled
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import torch | |
| # Creating the graph | |
| x = torch.tensor(1.0, requires_grad = True) | |
| # Check if tracking is enabled | |
| print(x.requires_grad) #True | |
| y = x * 2 | |
| print(y.requires_grad) #True | |
| with torch.no_grad(): | |
| # Check if tracking is enabled | |
| y = x * 2 | |
| print(y.requires_grad) #False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment