23 #include <logger/Log.hpp>
24 #include <logger/ConsoleOutput.hpp>
25 using namespace mic::logger;
31 #include <types/Batch.hpp>
36 using namespace mic::mlnn;
37 using namespace mic::types;
41 LOGGER->addOutput(
new ConsoleOutput());
44 size_t dataset_size = 15;
46 Batch<MatrixXf, MatrixXf> dataset;
47 for(
size_t i=0; i< dataset_size; i++) {
49 MatrixXfPtr pose (
new MatrixXf(dataset_size, 1));
52 dataset.data().push_back(pose);
55 MatrixXfPtr target (
new MatrixXf(classes, 1));
57 (*target)(i%classes,0)= 1;
58 dataset.labels().push_back(target);
61 dataset.indices().push_back(i);
75 while (iteration < 10000) {
76 Sample <MatrixXf, MatrixXf> sample = dataset.getRandomSample();
79 float loss = nn.
train(sample.data(), sample.label(), 0.1);
82 if (iteration % 1000 == 0)
83 std::cout<<
"[" << iteration <<
"]: Loss : " << loss << std::endl;
94 dataset.setNextSampleIndex(0);
95 while (iteration < dataset_size) {
96 Sample <MatrixXf, MatrixXf> sample = dataset.getNextSample();
97 std::cout <<
"[" << iteration++ <<
"]: sample (" << sample.index() <<
"): "<< sample.data()->transpose() <<
"->" << sample.label()->transpose() << std::endl;
99 float loss = nn.
test(sample.data(), sample.label());
102 std::cout<<
"Loss : " << loss << std::endl;
103 std::cout<<
"Targets : " << sample.label()->transpose() << std::endl;
104 std::cout<<
"Predictions : " << predictions.transpose() << std::endl << std::endl;
mic::types::MatrixPtr< eT > getPredictions()
eT test(mic::types::MatrixPtr< eT > encoded_batch_, mic::types::MatrixPtr< eT > encoded_targets_)
eT train(mic::types::MatrixPtr< eT > encoded_batch_, mic::types::MatrixPtr< eT > encoded_targets_, eT learning_rate_, eT decay_=0.0f)
Adam - adaptive moment estimation.
void pushLayer(LayerType *layer_ptr_)