How to get valid pixels from grid_sample()?

I’m using torch.nn.functional.grid_sample to warp an image, and I need to know which pixels came from outside the image.
This function supports “Zero” padding, but my image can have zeros in it as well, so I can’t search for zeros in the image for a valid pixels mask.
How to get valid pixels from grid_sample()?

Thnx

grid_sample will use the the padding values for all input values outside of [-1, 1] as explained in the docs. So you could check your input for these values.