From acdb58396c95d86218d5ec6a0118f2f483579cd9 Mon Sep 17 00:00:00 2001 From: Piv Date: Wed, 14 Apr 2021 12:45:01 +0930 Subject: [PATCH] Remove usage of keras --- losses.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/losses.py b/losses.py index 81f93e3..55c3c3f 100644 --- a/losses.py +++ b/losses.py @@ -1,5 +1,4 @@ import tensorflow as tf -import tensorflow.keras.backend as K def dense_depth_loss_function(y, y_pred): @@ -7,14 +6,14 @@ def dense_depth_loss_function(y, y_pred): Implementation of the loss from the dense depth paper https://arxiv.org/pdf/1812.11941.pdf """ # Point-wise L1 loss - l_depth = K.mean(K.abs(y_pred - y), axis=-1) + l_depth = tf.reduce_mean(tf.math.abs(y_pred - y), axis=-1) # L1 loss over image gradients dy, dx = tf.image.image_gradients(y) dy_pred, dx_pred = tf.image.image_gradients(y_pred) - l_grad = K.mean(K.abs(dy_pred - dy) + K.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) l_ssim = (1 - tf.image.ssim(y, y_pred, 500)) / 2 - return 0.1 * K.mean(l_depth) + l_grad + l_ssim + return 0.1 * tf.reduce_mean(l_depth) + l_grad + l_ssim