Done with activation softmax backwards
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user