Softmax + Categorical Crossentropy

I fixed the activation+loss function, you can't select it directly, it automaticly uses it if it can. I also fixed one-hot generator. Still haven't tested the activation + loss nor any other backward function. I'll do that when I get to the optimizers which is next.
This commit is contained in:
2026-08-06 09:53:03 +02:00
parent fecb4c70b1
commit 642bba1198
18 changed files with 627 additions and 378 deletions
+19 -1
View File
@@ -44,6 +44,14 @@ namespace panic{
enum struct layer_type {
unknown,
layer_dense,
activation_relu,
activation_softmax
};
/**
* @brief Base layer for the rest of the neural network library to use
*
@@ -85,6 +93,16 @@ struct layer{
virtual ~layer() = default;
/**
* @brief Virtual layer_type function for derivative layers
*
* @Note This returns the type of layer it is
* unknown be default
*/
virtual layer_type get_type() const {
return layer_type::unknown;
}
/**
* @brief Virtual forward function for derivative layers
*
@@ -103,7 +121,7 @@ struct layer{
* @Note It's equal to 0 because it make the derivative
* object NEEDS to have these function to work.
*/
virtual bool backward(const panic::tensor::real_matrix& dinputs) = 0;
virtual bool backward(const panic::tensor::real_matrix& dvalues) = 0;
};
+10 -24
View File
@@ -58,30 +58,6 @@ namespace panic{
*/
struct layer_dense : trainable_layer{
/**
* @brief Emphty matrix to store input data
*
*/
panic::tensor::real_matrix ipnuts;
/**
* @brief Emphty weight matrix to store layer weights
*
* Weight shape:
* input_size x neuron_count
*/
panic::tensor::real_matrix weights;
panic::tensor::real_matrix dweights;
/**
* @brief Emphty bias vector to store layer bias
*
* Bias shape:
* 1 x neuron_count
*/
panic::tensor::real_vector biases;
panic::tensor::real_vector dbiases;
/**
* @brief Empthy constructor
*
@@ -103,6 +79,16 @@ struct layer_dense : trainable_layer{
*/
~layer_dense() = default;
/**
* @brief get_type function for layer
*
* @returns the layer type
*
*/
layer_type get_type() const override {
return layer_type::layer_dense;
}
/**
* @brief Forward function for layer
*