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
+28 -19
View File
@@ -88,15 +88,6 @@
// #define TEST_FALG 1
//---------------------------------------------------------------------------------------------------------------------------
// Function Name : benchmark_omp_min_work
//
@@ -725,28 +716,46 @@ int main(void) {
panic::neural_network::model mymodel;
// Create Dense layer with 2 input features and 3 output values
mymodel.add_layer_dense(2,3);
if (!mymodel.add_layer_dense(2,3)){
return false;
}
// Create an activation ReLU layer
mymodel.add_activation_relu();
if (!mymodel.add_activation_relu()){
return false;
}
// Create a second dense layer with 3 inputs and 3 outputs
mymodel.add_layer_dense(3, 3);
if (!mymodel.add_layer_dense(3, 3)){
return false;
}
// Create activation softmax layer
mymodel.add_activation_softmax();
if (!mymodel.add_activation_softmax()){
return false;
}
mymodel.add_loss_categorical_crossentropy();
//mymodel.activation_softmax_loss_categorical_crossentropy();
if (!mymodel.add_loss_categorical_crossentropy()){
return false;
}
if (!mymodel.finalize()){
return false;
}
mymodel.add_optimizer_sgd();
//mymodel.add_optimizer_sgd();
panic::types::uint_t epochs = 10;
panic::types::uint_t print_every = 1;
mymodel.train(X, y, epochs, print_every);
if (!mymodel.train(X, y, epochs, print_every)){
std::cout << "Training failed" << std::endl;
return false;
}
return 0;