Hi, Thanks for your reply. Because the tf.slice operation is " This operation extracts a slice of size size from a tensor input starting at the location specified by begin . The slice size is represented as a tensor shape, where size[i] is the number of elements of the 'i’th dimension of input that you want to slice. The starting location ( begin ) for the slice is represented as an offset in each dimension of input". So I dont think their coding wrong.
But for Pytorch, you are right. we need to give the same width. So i changed it following your guide like this:
def get_loss(self, image):
b, c, h, w = image.size()
horizontal_normal = image[:, :, :, 0:w-1]
horizontal_one_right = image[:, :, :, 1:w]
vertical_normal = image[:, :, 0:h-1, :]
vertical_one_right = image[:, :, 1:h, :]
loss = torch.pow(horizontal_normal-horizontal_one_right, 2).sum() / \
2. + torch.pow(vertical_normal - vertical_one_right, 2).sum()/2.0
return loss
I hope it get same operation with tf.slice in this case ^^