How to print out the gradient of each parameter?

Can someone give an example of printing out the gradient of each parameter in learn.model?

Try this:

for p in learn.model.parameters():
 if p.grad is not None: print(p.grad)
1 Like

Thanks. Where do I insert these two lines? Normally I do

Learn.lr_find()
Learn.recorder.plot()
Learn.fit_one_cycle()