Fix loss function
This commit is contained in:
@@ -11,9 +11,10 @@ def dense_depth_loss_function(y, y_pred):
|
|||||||
# L1 loss over image gradients
|
# L1 loss over image gradients
|
||||||
dy, dx = tf.image.image_gradients(y)
|
dy, dx = tf.image.image_gradients(y)
|
||||||
dy_pred, dx_pred = tf.image.image_gradients(y_pred)
|
dy_pred, dx_pred = tf.image.image_gradients(y_pred)
|
||||||
l_grad = tf.reduce_mean(tf.math.abs(dy_pred - dy) + tf.math.abs(dx_pred - dx), axis=-1)
|
l_grad = tf.reduce_mean(tf.math.abs(dy_pred - dy) +
|
||||||
|
tf.math.abs(dx_pred - dx), axis=-1)
|
||||||
|
|
||||||
# Structural Similarity (SSIM)
|
# Structural Similarity (SSIM)
|
||||||
l_ssim = (1 - tf.image.ssim(y, y_pred, 500)) / 2
|
l_ssim = (1 - tf.image.ssim(y, y_pred, 500)) / 2
|
||||||
|
|
||||||
return 0.1 * tf.reduce_mean(l_depth) + l_grad + l_ssim
|
return 0.1 * tf.reduce_mean(l_depth) + tf.reduce_mean(l_grad) + l_ssim
|
||||||
|
|||||||
Reference in New Issue
Block a user