File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 64
64
# documentation <https://pytorch.org/docs/stable/autograd.html#function>`__.
65
65
#
66
66
67
- print (' Gradient function for z =' , z .grad_fn )
68
- print (' Gradient function for loss =' , loss .grad_fn )
67
+ print (f" Gradient function for z = { z .grad_fn } " )
68
+ print (f" Gradient function for loss = { loss .grad_fn } " )
69
69
70
70
######################################################################
71
71
# Computing Gradients
206
206
inp = torch .eye (5 , requires_grad = True )
207
207
out = (inp + 1 ).pow (2 )
208
208
out .backward (torch .ones_like (inp ), retain_graph = True )
209
- print ("First call\n " , inp .grad )
209
+ print (f "First call\n { inp .grad } " )
210
210
out .backward (torch .ones_like (inp ), retain_graph = True )
211
- print ("\n Second call\n " , inp .grad )
211
+ print (f "\n Second call\n { inp .grad } " )
212
212
inp .grad .zero_ ()
213
213
out .backward (torch .ones_like (inp ), retain_graph = True )
214
- print ("\n Call after zeroing gradients\n " , inp .grad )
214
+ print (f "\n Call after zeroing gradients\n { inp .grad } " )
215
215
216
216
217
217
######################################################################
You can’t perform that action at this time.
0 commit comments