Save
I've created the optimizer class
This commit is contained in:
@@ -63,6 +63,7 @@
|
||||
#include <math/argmax.hpp>
|
||||
#include <math/equal.hpp>
|
||||
#include <math/mean.hpp>
|
||||
#include <neural_network/activation_loss/activation_softmax_loss_categorical_crossentropy.hpp>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
@@ -735,32 +736,15 @@ int main(void) {
|
||||
// Create activation softmax layer
|
||||
mymodel.add_activation_softmax();
|
||||
|
||||
// create loss function
|
||||
panic::neural_network::loss_categorical_crossentropy loss_function;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
mymodel.add_loss_categorical_crossentropy();
|
||||
//mymodel.activation_softmax_loss_categorical_crossentropy();
|
||||
|
||||
mymodel.add_optimizer_sgd();
|
||||
|
||||
panic::types::uint_t epochs = 10;
|
||||
panic::types::uint_t print_every = 1;
|
||||
|
||||
|
||||
mymodel.train(X, y, epochs, print_every);
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user