Calculations with Paramaters

I would like to calculate the following: w(k)−w(k−1), where w(k) are the parameters in iteration k. How can I make such a calculation?

Additionally, I would like to calculate the following: f(w(k)) + g(w(k)) where f and g are two separate functions of the parameters. Again, how can I make this calculation?

Thank you for your help.

I’d probably use the module.state_dict() to get the values of parameters before and after the iteration. You might want to move them to the cpu to not use the GPU memory.

Best regards

Thomas

1 Like