Why categorical_crossentropy gives 16?

24 Views Asked by At

I'm trying to calculate the math behind the code:

import tensorflow as tf
import numpy as np



y_pred_one_hot = np.array([0, 0, 0, 1], dtype='float32')
y_true_one_hot = np.array([0, 1, 0, 0], dtype='float32')


res = tf.keras.losses.categorical_crossentropy(y_true_one_hot,y_pred_one_hot,from_logits=False)
round(res.numpy() , 3)

gives = 16.118

I'm using the equation:

enter image description here

  1. log(0) is error ? so how I'm getting 16 ?
  2. ti and pi have 0 in same indexes, so the sum doesn't need be 0 ?

what am I missing behaind the math ?

0

There are 0 best solutions below