AIfES 2
2.0.0
|
General Cross-Entropy loss struct. More...
#include <ailoss_crossentropy.h>
Data Fields | |
ailoss_t | base |
Inherited field members from general ailoss struct. | |
const aimath_dtype_t * | dtype |
Main data type of the loss. | |
Math functions | |
Required data type specific math functions | |
void(* | tensor_sub )(const aitensor_t *a, const aitensor_t *b, aitensor_t *result) |
Required math function: Element wise tensor subtraction. More... | |
void(* | crossentropy )(const aitensor_t *predicted_data, const aitensor_t *target_data, void *result) |
Required math function: Cross-Entropy between two tensors. More... | |
void(* | scale_by_batch_size )(const aitensor_t *predicted_data, aitensor_t *result) |
Required math function: Scaling of the gradient tensor. More... | |
General Cross-Entropy loss struct.
void(* crossentropy) (const aitensor_t *predicted_data, const aitensor_t *target_data, void *result) |
Required math function: Cross-Entropy between two tensors.
Requires a math function that calculates the Cross-Entropy between two tensors.
For a Sigmoid output layer it should be the binary Cross-Entropy:
\[ result = -\sum (target \cdot \log(predicted) + (1 - target) \log(1 - predicted)) \]
For a Softmax output layer it should be the categorical Cross-Entropy:
\[ result = -\sum target \cdot \log(predicted) \]
result | A Scalar of the defined data type |
void(* scale_by_batch_size) (const aitensor_t *predicted_data, aitensor_t *result) |
Required math function: Scaling of the gradient tensor.
Requires a math function that scales a tensor by its batch size:
void(* tensor_sub) (const aitensor_t *a, const aitensor_t *b, aitensor_t *result) |
Required math function: Element wise tensor subtraction.
Requires a math function that subtracts two tensors element wise:
\[ result = a - b \]