Tensorflow Loss Function

Hi Sir,

How can we find the code written for tensorflow categorial entropy loss or binary loss function in tensorflow ? Because we see in the documentation or github only the direct aip used ? But we would like to know how the actual code written behind the loss function ?

How we can find the code ? Please help

  1. tf.keras.losses.BinaryCrossentropy  |  TensorFlow Core v2.7.0

  2. keras/losses.py at v2.7.0 · keras-team/keras · GitHub

  3. tf.keras.metrics.binary_crossentropy  |  TensorFlow Core v2.7.0

  4. tensorflow/backend.py at master · tensorflow/tensorflow · GitHub

This omits some of the call stack details, such as the Loss and LossFunctionWrapper base class init and call functions, but that is the basic breadcrumb trail for Binary_Crossentropy that ends with


  # Compute cross entropy from probabilities.
  bce = target * math_ops.log(output + epsilon())
  bce += (1 - target) * math_ops.log(1 - output + epsilon())
  return -bce