| AIfES 2 2.0.0

ailoss_crossentropy.h
Go to the documentation of this file.
1
50 #ifndef CROSSENTROPY_LOSS
51 #define CROSSENTROPY_LOSS
52
53 #include "core/aifes_core.h"
54 #include "basic/base/ailayer/ailayer_softmax.h"
55 #include "basic/base/ailayer/ailayer_sigmoid.h"
56
57 typedef struct ailoss_crossentropy ailoss_crossentropy_t;
62 struct ailoss_crossentropy {
63 ailoss_t base;
64 const aimath_dtype_t *dtype;
70
78 void (*tensor_sub)(const aitensor_t *a, const aitensor_t *b, aitensor_t *result);
79
95 void (*crossentropy)(const aitensor_t *predicted_data, const aitensor_t *target_data, void *result);
96
102 void (*scale_by_batch_size)(const aitensor_t *predicted_data, aitensor_t *result);
103
105 };
106
112 extern const aicore_losstype_t *ailoss_crossentropy_type;
113
125 ailoss_t *ailoss_crossentropy(ailoss_crossentropy_t *loss, ailayer_t *input_layer);
126
152 void ailoss_crossentropy_calc_delta(ailoss_t *self, const aitensor_t *target_data);
153
184 void ailoss_crossentropy_calc_loss(ailoss_t *self, const aitensor_t *target_data, void *result);
185
198 void ailoss_crossentropy_dummy_backward(ailayer_t *self);
199
200 #ifdef AIDEBUG_PRINT_MODULE_SPECS
205 void ailoss_crossentropy_print_specs(const ailoss_t *self);
206 #endif // AIDEBUG_PRINT_MODULE_SPECS
207
208 #endif // CROSSENTROPY_LOSS
aifes_core.h
AIfES 2 core interface.
ailayer_sigmoid.h
Base layer implementation of the Sigmoid activation layer.
ailayer_softmax.h
Base layer implementation of the Softmax activation layer.
ailoss_crossentropy
ailoss_t * ailoss_crossentropy(ailoss_crossentropy_t *loss, ailayer_t *input_layer)
Initialize and connect the given Cross-Entropy loss.
ailoss_crossentropy_calc_delta
void ailoss_crossentropy_calc_delta(ailoss_t *self, const aitensor_t *target_data)
Calculate the combined derivative of the given Cross-Entropy loss and the output layer for error back...
ailoss_crossentropy_dummy_backward
void ailoss_crossentropy_dummy_backward(ailayer_t *self)
Dummy backward-function for the output layer of the model.
ailoss_crossentropy_type
const aicore_losstype_t * ailoss_crossentropy_type
Cross-Entropy loss type.
ailoss_crossentropy_calc_loss
void ailoss_crossentropy_calc_loss(ailoss_t *self, const aitensor_t *target_data, void *result)
Calculate the Cross-Entropy loss on the given target data.
ailoss_crossentropy_print_specs
void ailoss_crossentropy_print_specs(const ailoss_t *self)
Print the loss specification.
aicore_losstype
Type indicator of the loss to check for the loss type.
Definition: aifes_core.h:121
ailayer
AIfES layer interface.
Definition: aifes_core.h:252
ailoss_crossentropy
General Cross-Entropy loss struct.
Definition: ailoss_crossentropy.h:62
ailoss_crossentropy::tensor_sub
void(* tensor_sub)(const aitensor_t *a, const aitensor_t *b, aitensor_t *result)
Required math function: Element wise tensor subtraction.
Definition: ailoss_crossentropy.h:78
ailoss_crossentropy::scale_by_batch_size
void(* scale_by_batch_size)(const aitensor_t *predicted_data, aitensor_t *result)
Required math function: Scaling of the gradient tensor.
Definition: ailoss_crossentropy.h:102
ailoss_crossentropy::dtype
const aimath_dtype_t * dtype
Main data type of the loss.
Definition: ailoss_crossentropy.h:64
ailoss_crossentropy::crossentropy
void(* crossentropy)(const aitensor_t *predicted_data, const aitensor_t *target_data, void *result)
Required math function: Cross-Entropy between two tensors.
Definition: ailoss_crossentropy.h:95
ailoss_crossentropy::base
ailoss_t base
Inherited field members from general ailoss struct.
Definition: ailoss_crossentropy.h:63
ailoss
AIfES loss interface.
Definition: aifes_core.h:385
aimath_dtype
Indicator for the used datatype.
Definition: aifes_math.h:44
aitensor
A tensor in AIfES.
Definition: aifes_math.h:89