I am trying to create a loss function in Keras (Tensorflow Backend) but I am a little stuck to check the inside of the custom loss function. In fact, the print appears on the console only when I compile the model, after that there is no print. (I am just testing very simple custom function, I will create the true function when I solved this problem). I train the model using the train_on_batch
function. How can I solve this problem?
def loss_yolo(self, y_true, y_pred):
print('inside loss function')
loss = K.mean(y_true - y_pred)
return loss
model.compile(optimizer='sgd', loss=loss_yolo)
print('train on batch')
print(model.train_on_batch(x, y))
And the output is
inside loss function
train on batch
-0.481604