Backpropagate through part of input data

Hi there,

Now I’m working on a project that needs to generate hundreds of adversarial copies for one batch on ImageNet. In terms of saving memory and running time, we want to only add perturbation(calculate gradient) on the images that are not correctly classified. Is it possible to implement it in torch?

Thanks in advance!