I\'m writing a custom objective to train a Keras (with TensorFlow backend) model but I need to debug some intermediate computation. For simplicity, let\'s say I have:
In TensorFlow 2.0, you can use tf.print and print anything inside the definition of your loss function. You can also do something like tf.print("my_intermediate_tensor =", my_intermediate_tensor)
, i.e. with a message, similar to Python's print
. However, you may need to decorate your loss function with @tf.function to actually see the results of the tf.print
.