commit ef8e1d8448ec1dcac13f868ba3e90461ebc7d558
parent 6613b279c2baa0a8aa7fcfc3a399a080960953e3
Author: David Freifeld <freifeld.david@gmail.com>
Date: Mon, 3 Aug 2020 18:03:51 -0700
Adding progress bar
Diffstat:
2 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/example.cpp b/example.cpp
@@ -5,6 +5,10 @@
// Created by David Freifeld
//
+#include <indicators/cursor_control.hpp>
+#include <indicators/progress_bar.hpp>
+#include <indicators/block_progress_bar.hpp>
+using namespace indicators;
#include "./src/bpnn.hpp"
#include "./src/utils.hpp"
#include "unistd.h"
@@ -17,7 +21,6 @@ double bench(int batch_sz)
net.add_layer(4, "linear");
net.add_layer(5, "relu");
net.add_layer(2, "linear");
- net.init_optimizer("nesterov", 0.9);
net.initialize();
for (int i = 0; i < 50; i++) {
net.train();
@@ -28,5 +31,26 @@ double bench(int batch_sz)
int main()
{
- bench(16);
+ show_console_cursor(false);
+ BlockProgressBar bar{
+ option::BarWidth{80},
+ option::Start{"["},
+ option::End{"]"},
+ option::ForegroundColor{Color::white} ,
+ option::FontStyles{std::vector<FontStyle>{FontStyle::bold}}
+ };
+ Network net ("./data_banknote_authentication.txt", 16, 0.0155, 0.03, 2, 0, 0.9);
+ net.add_layer(4, "linear");
+ net.add_layer(5, "relu");
+ net.add_layer(2, "linear");
+ net.initialize();
+ bar.set_option(option::PostfixText{"Starting train"});
+ for (int i = 0; i < 5000; i++) {
+ net.train();
+ char msg[32];
+ sscanf(msg, "Finished epoch %i", i);
+ std::string str(msg);
+ bar.set_option(option::PostfixText{"#po0fso"});
+ bar.set_progress((float)i/5000 * 100);
+ }
}
diff --git a/src/bpnn.cpp b/src/bpnn.cpp
@@ -11,6 +11,7 @@
#include <random>
#include <Eigen/MatrixFunctions>
#include <Eigen/unsupported/CXX11/Tensor>
+#include <indicators/progress_bar.hpp>
#define SHUFFLED_PATH "./shuffled.txt"
#define VAL_PATH "./test.txt"
@@ -550,7 +551,7 @@ void Network::train()
epoch_acc = 1.0/((float) instances/batch_size) * acc_sum;
epoch_cost = 1.0/((float) instances/batch_size) * cost_sum;
validate(VAL_PATH);
- printf("Epoch %i complete - cost %f - acc %f - val_cost %f - val_acc %f\n", epochs, epoch_cost, epoch_acc, val_cost, val_acc);
+ //printf("Epoch %i complete - cost %f - acc %f - val_cost %f - val_acc %f\n", epochs, epoch_cost, epoch_acc, val_cost, val_acc);
batches=1;
rewind(data);
decay();