Adjusting weights of autoencoders based on known output per iteration

Hi

I am trying to mimic a mathematical iterative optimization using Autoencoders. I want to learn this network in same manner, just like this optimization does. I would like to take output of each iteration of this optimization using pytorch, and then adjust the weights of the autoencoder network, so the output for this network iteration is same as the optimization.

Any suggestions?

Thanks
Sal