Zero_grad() for input image Variable?

Hi,

I know there is a zero_grad function for the network, e.g.,

scores=vgg16(image)
vgg16.zero_grad()

When I do backward pass for the network, the image also get some gradient, right? If I want to zero all the grad for the image, how can I do it?

image is a Variable; image.zero_grad() will has en error.

Thanks!

image.grad.data.zero_()

1 Like

Thanks! WIll try this.