categorical_crossentropy¶
dragon.vm.tensorflow.keras.losses.
categorical_crossentropy
(
y_true,
y_pred,
axis=- 1,
reduction='mean'
)[source]¶Compute the categorical cross entropy with contiguous targets.
Examples:
y_true = tf.constant([[0., 1.], [1., 0.]]) y_pred = tf.constant([[0.5, 0.5], [0.3, 0.7]]) print(tf.keras.cost.categorical_crossentropy(y_true, y_pred)) # 0.8030813
- Parameters:
- y_true (dragon.Tensor) – The ground truth tensor.
- y_pred (dragon.Tensor) – The logits tensor.
- axis (int, optional, default=-1) – The reduction axis.
- reduction ({'none', 'sum', 'mean'}, optional) – The reduction method.
- Returns:
dragon.Tensor – The loss.