title: Creating a custom loss function in tf.keras
body: <p>I'm learning about various loss functions used in Deep learning. I needed some help implementing a custom loss function in tensorflow. To get a concrete picture of this, I would like to implement a custom Binary Cross Entropy loss as an example. </p>
  
  <p>Thanks a lot for your help</p>
  
  <p>Regards</p>
  
  <p>Edit:
  The following is loss function I have implemented:</p>
  
  <pre><code>def custom_loss(eps):
      def loss(y_true, y_pred):
          ans = -eps*(y_true*tf.log(y_pred) + (1-y_true)*tf.log(y_pred))
          return ans
      return loss
  </code></pre>
  
  <p>This is returning not a number after sometime. I tried to add a small quantity to the log function. Furthermore, I have changed the optimiser to adam.</p>