adityakovvali:

when I back-propagate with the custom loss, I want to update only certain pixels of the image and keep the other pixels as they are.


the loss is just for some pixels or all pixels? I don’t know how to help, but these two links may help

https://pytorch.org/docs/stable/autograd.html#torch.Tensor.register_hook 4

https://github.com/albertpumarola/GANimation 6 (they use a mask to only change the ROIs)