Hello,Thank you for sharing your code.I want to know some detail about the loss function.
In the function,what does logits
and factor_lambda
mean? Is boundary_target
the predicted result?
Thanks.
`def refine_loss(logits, labels, boundary_target):
gamma1 = 0.5
gamma2 = 1-gamma1
factor_lambda= 1.5
dy_logits, dx_logits = tf.image.image_gradients(logits)
dy_labels, dx_labels = tf.image.image_gradients(labels)
# magnitudes of logits and labels gradients
Mpred = tf.sqrt(tf.square(dy_logits)+tf.square(dx_logits))
Mimg = tf.sqrt(tf.square(dy_labels)+tf.square(dx_labels))
# define cos loss and mag loss
cosL = (1-tf.abs(dx_labels*dx_logits+dy_labels*dy_logits))*Mpred
magL = tf.maximum(factor_lambda*Mimg-Mpred,0)
# define mask
M_bound = boundary_target/255.
# define total refine loss
refineLoss = (gamma1*cosL + gamma2*magL)*M_bound
return tf.reduce_mean(refineLoss)
# return tf.reduce_mean(refineLoss), Mpred, Mimg`