the tensorflow version：
import tensorflow as tf
import math
def wing_loss(landmarks, labels, w=10.0, epsilon=2.0):
“”"
Arguments:
landmarks, labels: float tensors with shape [batch_size, num_landmarks, 2].
w, epsilon: a float numbers.
Returns:
a float tensor with shape [].
“”"
with tf.name_scope(‘wing_loss’):
x = landmarks - labels
c = w * (1.0 - math.log(1.0 + w/epsilon))
absolute_x = tf.abs(x)
losses = tf.where(
tf.greater(w, absolute_x),
w * tf.log(1.0 + absolute_x/epsilon),
absolute_x - c
)
loss = tf.reduce_mean(tf.reduce_sum(losses, axis=[1, 2]), axis=0)
return loss
i want to use wing loss from CVPR2018 to train my networks, but i cant transform it to pytorch. Very thanks for somebody can do it. It is a very good loss. You can use it in Linear Regression.