title: How do I print inside the loss function during training in Keras?
body: <p>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 <code>train_on_batch</code> function. How can I solve this problem?</p>
  <pre><code>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))
  </code></pre>
  <p>And the output is</p>
  <blockquote>
  <p>inside loss function</p>
  <p>train on batch</p>
  <p>-0.481604</p>
  </blockquote>