Q:

AttributeError: 'Tensor' object has no attribute 'numpy' in custom loss function (Tensorflow 2.1.0)

I want to train a model with a custom loss function, in order to do that, I need to convert the tensor to numpy array inside the method below:
def median_loss_estimation(y_true, y_predicted):
    a = y_predicted.numpy()

but I have this error:
AttributeError: 'Tensor' object has no attribute 'numpy'

Why?
How can I convert the tensor to a numpy array?

A:

The answer is: put run_eagerly=True in model.compile!

