Categorical Crossentropy
Functions
categorical_crossentropy(Y, Y_hat)
Calculate the categorical cross-entropy loss.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Y |
ndarray
|
True labels in one-hot encoded format. |
required |
Y_hat |
ndarray
|
Predicted probabilities for each class. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
The categorical cross-entropy loss. |
Example
Note
A small epsilon (1e-8) is added to the log to avoid numerical instability when Y_hat contains zero probabilities.