Hello, I want to implement smooth Loss function for image by following the ImageDenoisingGAN paper (in this paper, they calculate the smooth loss by slide a copy of the generated image one unit to the left and one unit down and then take an Euclidean distance between the shifted images). so far their tensorflow coding like this :
def get_smooth_loss(image):
    batch_count = tf.shape(image)[0]
    image_height = tf.shape(image)[1]
    image_width = tf.shape(image)[2]

    horizontal_normal = tf.slice(image, [0, 0, 0,0], [batch_count, image_height, image_width-1,3])
    horizontal_one_right = tf.slice(image, [0, 0, 1,0], [batch_count, image_height, image_width-1,3])
    vertical_normal = tf.slice(image, [0, 0, 0,0], [batch_count, image_height-1, image_width,3])
    vertical_one_right = tf.slice(image, [0, 1, 0,0], [batch_count, image_height-1, image_width,3])
    smooth_loss = tf.nn.l2_loss(horizontal_normal-horizontal_one_right)+tf.nn.l2_loss(vertical_normal-vertical_one_right)
return smooth_loss

I want to convert this Tensorflow code to Pytorch but still can’t figure it out. Could someone help to convert it to Pytorch or any suggestion?
Thanks