def forward(self, x):
"""Return the deformed featured map"""
x_shape = x.size()
offsets = F.conv2d(x, self.weight, self.bias, self.stride,
self.padding, self.dilation, self.groups)
# offsets: (b*c, h, w, 2)
offsets = self._to_bc_h_w_2(offsets, x_shape)
# x: (b*c, h, w)
x = self._to_bc_h_w(x, x_shape)
# X_offset: (b*c, h, w)
x_offset = th_batch_map_offsets(x, offsets, grid=self._get_grid(self,x))
# x_offset: (b, h, w, c)
x_offset = self._to_b_c_h_w(x_offset, x_shape)
return x_offset
评论列表
文章目录