Access model weights during training #13966
-
Hello and thanks for this amazing library. When training models I find useful checking which parameters change after backpropagation. In vanilla Pytorch I would do something like
And I should see a bunch of ones. Some zeroes can indicate branches of the network where the gradients are not flowing back. I was thinking of a callback that does the same within PL. After reading the docs, I have came up with this:
Nevertheless, I believe that pl_module.parameters() is not returning the actual parameters used in the optimization, as I am always getting zeroes printed out, even if other indicators (loss/metrics) suggest the model is being trained well. How can I access the model parameters during training process? Thanks a lot and best wishes, Victor |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
you should see or you did see. I think the parameters saved in the dict are references to the same object hence you can't see any difference there.
also, this is a generator. you can deepcopy the state_dict instead to verify it. |
Beta Was this translation helpful? Give feedback.
you should see or you did see. I think the parameters saved in the dict are references to the same object hence you can't see any difference there.
also, this is a generator.
you can deepcopy the state_dict instead to verify it.