I am implementing own Keras loss function. How can I access tensor values?
What I\'ve tried
def loss_fn(y_true, y_pred):
print y_true
If you are using TensorFlow's keras, you can enable Eager Execution:
import tensorflow as tf
tf.enable_eager_execution()
Afterwards you can print the tensors in your loss function.
In case you get the error message "ValueError: Only TF native optimizers are supported in Eager mode." and you have used 'adam' as an optimizer for example, you can change the model's compile arguments to
model.compile(optimizer = tf.train.AdamOptimizer(), loss = loss_fn, ...)