Done with activation softmax backwards

This commit is contained in:
2026-07-31 19:08:57 +02:00
parent d7b74ab40f
commit 11da534fd6
30 changed files with 3029 additions and 184 deletions
+29 -2
View File
@@ -59,6 +59,10 @@
#include <math/exp.hpp>
#include <math/sub.hpp>
#include <neural_network/loss/loss_categorical_crossentropy.hpp>
#include <math/log.hpp>
#include <math/argmax.hpp>
#include <math/equal.hpp>
#include <math/mean.hpp>
#include <math.h>
@@ -731,12 +735,35 @@ int main(void) {
// Create activation softmax layer
mymodel.add_activation_softmax();
mymodel.forward(X);
// create loss function
panic::neural_network::loss_categorical_crossentropy loss_function;
panic::io::print_matrix(mymodel.outputs);
mymodel.forward(X);
loss_function.calculate(mymodel.outputs, y);
panic::tensor::uint_vector prediction;
prediction = panic::math::argmax_rowwise(mymodel.outputs);
panic::types::real_t accuracy;
panic::tensor::uint_vector comparisons;
comparisons = panic::math::equal(prediction, y);
accuracy = panic::math::mean(comparisons);
std::cout << "loss: " << loss_function.data_loss << std::endl;
std::cout << "acc: " << accuracy << std::endl;
return 0;
}