Hi, thanks for helping me out. The code is running now. But I am facing another difficulty, that my patch_model is not changing it’s parameters. On further inspection, the grad of all parameters is 0 after running the epoch. I tried removing .clone from _temp in my apply_to_img but the result is same. Any insight regarding this would be very much helpful. One more change I made in apply_to_patch was I clamped my patch from (0, 1) so that the values are in the range of pixel values.
For reference in the epoch function, I am calling it this way:
epoch(train_loader, model.eval(), opt)
where model is pretrained model for MNIST