'tensorflow: logging custom loss function?

I've written a custom loss function as follows:

def distance_loss(y_actual, y_pred):
    return tf.math.sqrt(
            tf.math.add(
                tf.math.pow(
                    tf.math.subtract(y_actual[0], y_pred[0]),
                    tf.constant(2.0)
                ),
                tf.math.pow(
                    tf.math.subtract(y_actual[1], y_pred[1]),
                    tf.constant(2.0)
                )
            )
        )

However this is my first time doing this so I don't know how well (or if) this function is working.

Is there any way I can log the inputs and output of this function, as well as the sample it's being called on, so I can manually verify that it's working as intended?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source