rakutentech / stAdv

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

Incorrect implementation of flow_st() #1

Closed anianruoss closed 6 years ago

anianruoss commented 6 years ago

In my opinion, lines 114 - 117 in layers.py should be:

wa = (1. - (sampling_grid_x - x0)) * (1. - (sampling_grid_y - y0))
wb = (1. - (sampling_grid_x - x0)) * (1. - (y1 - sampling_grid_y))
wc = (1. - (x1 - sampling_grid_x)) * (1. - (sampling_grid_y - y0))
wd = (1. - (x1 - sampling_grid_x)) * (1. - (y1 - sampling_grid_y))

instead of:

wa = (x1 - sampling_grid_x) * (y1 - sampling_grid_y)
wb = (x1 - sampling_grid_x) * (sampling_grid_y - y0)
wc = (sampling_grid_x - x0) * (y1 - sampling_grid_y)
wd = (sampling_grid_x - x0) * (sampling_grid_y - y0)

according to eq. (1) in Xiao et al.

Am I missing something?

berangerd commented 6 years ago

x1 and y1 are defined as follows in layers.py:

x1 = x0 + 1
y1 = y0 + 1

so these two definitions of the wa, wb, wc, wd are equivalent.

The implementation of the bilinear interpolation has been tested against the one from scikit-image (up to boundary effects) in https://github.com/rakutentech/stAdv/blob/master/tests/test_layers.py#L144

anianruoss commented 6 years ago

Yes, of course. Thank you!