jacobian

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 24810ffa46552c6a5853147122b3bfb0f68012fd
parent 54eb5eb8503f3dc3c5b5902fe159e173f065979c
Author: David Freifeld <freifeld.david@gmail.com>
Date:   Sun, 21 Jun 2020 18:34:17 -0700

Further attempts to improve training

Diffstat:
Mbpnn.cpp | 19+++++++++++++++----
Mmr_bpnn_2.cpp | 3++-
2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/bpnn.cpp b/bpnn.cpp @@ -37,6 +37,7 @@ void Layer::initWeights(Layer next) } } +// Testing 123 Network::Network(char* path, int inputs, int hidden, int outputs, int neurons, int batch_sz, float rate) { learning_rate = rate; @@ -175,6 +176,7 @@ void Network::update_layer(float* vals, int datalen, int index) } } +// LSP is cool int Network::next_batch(char* path) { FILE* fptr = fopen(path, "r"); @@ -199,7 +201,6 @@ int Network::next_batch(char* path) float* batchptr = batch; update_layer(batchptr, datalen, 0); fclose(fptr); - return 0; } @@ -242,11 +243,13 @@ float Network::test(char* path) int datalen = batch_size * inputs; float batch[datalen]; int label = -1; + printf("End line is %i\n", batch_size*((i/batch_size)+1)); for (int j = 1; j < batch_size*((i/batch_size)+1); j++) { if (fgets(line, 1024, fptr)==NULL) { break; } - if (i >= batches*batch_size) { + printf("End line is %i\n", batch_size*((i/batch_size)+1)); + if (i >= (i/batch_size)*batch_size) { int k = i - ((i/batch_size)*batch_size); sscanf(line, "%f,%f,%f,%f,%i", &batch[0 + (k * inputs)], &batch[1 + (k * inputs)], &batch[2 + (k * inputs)], @@ -257,6 +260,7 @@ float Network::test(char* path) float* batchptr = batch; update_layer(batchptr, datalen, 0); fclose(fptr); + std::cout << "Batch is: \n"<< *layers[0].contents << "\n and labels \n" << *labels << "\n"; cost_sum += cost(); acc_sum += accuracy(); finalcount = i; @@ -319,6 +323,13 @@ void demo(int total_epochs) net.batches=1; epochs++; } - net.list_net(); - printf("Test accuracy: %f\n", net.test("./test.txt")); + + // float newvals[4] = {0}; + // FILE* new = fopen("./predict.txt", "r"); + // fscanf(new, "%f, %f, %f, %f", &newvals[0], &newvals[1], &newvals[2], &newvals[3]); + // net.update_layer(newvals, 4, 0); + // net.feedforward(); + // net.list_net(); + //net.list_net(); + // printf("Test accuracy: %f\n", net.test("./test.txt")); } diff --git a/mr_bpnn_2.cpp b/mr_bpnn_2.cpp @@ -107,7 +107,8 @@ int main(int argc, char** argv) { auto prog_begin = std::chrono::high_resolution_clock::now(); prep_file(argv[2], "./shuffled"); - begin("./shuffled", map, reduce, translate, strtol(argv[1], NULL, 10), 1, argv[3], strtol(argv[4], NULL, 10)); + //begin("./shuffled", map, reduce, translate, strtol(argv[1], NULL, 10), 1, argv[3], strtol(argv[4], NULL, 10)); + demo(50); auto prog_end = std::chrono::high_resolution_clock::now(); std::cout << "Time: " << std::chrono::duration_cast<std::chrono::nanoseconds>(prog_end-prog_begin).count() / pow(10,9) << "\n";