rakutentech / stAdv

Spatially Transformed Adversarial Examples with TensorFlow
MIT License
72 stars 18 forks source link

How to gather slices for single channel images? #10

Closed YanghaoZYH closed 4 years ago

YanghaoZYH commented 4 years ago

Hi Berangerd,

Thanks for releasing the code for spatial transformation. I have a question for these rows for getting pixel value at corner coordinates in layer.py

Ia = tf.gather_nd(images, tf.stack([b, y0, x0], 3), name='Ia')

The shape of the indices will be [B, H, W, 3]. For color images with shape [B, H, W, 3], after gathering slices, it gets the output with shape [B, H, W, 3].

But for the singe channel images with shape [B, H, W, 1], I do not understand how to gather the slices given the indices [B, H, W, 3] via tf.gather_nd and get the output with [B, H, W, 1]?

Could you please guide me in understanding how this works? Thanks for your help!