jacobian

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

commit 1a9db6adece3fe6a47ca89f6a80b4ad80305523f
parent a7fe06e8ae99bb5ef61bec435ad0b2d3949d2619
Author: David Freifeld <freifeld.david@gmail.com>
Date:   Sat, 11 Jul 2020 23:15:58 -0700

Switching to softmax

Diffstat:
Mexample.cpp | 9+++++----
Msrc/bpnn.cpp | 9+++++++++
2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/example.cpp b/example.cpp @@ -10,12 +10,13 @@ double bench(int batch_sz) net.add_layer(4, "linear"); net.add_layer(5, "relu"); net.add_layer(2, "linear"); - net.init_decay("step", 0, 2); + net.init_decay("exp", 1, 10); net.initialize(); // checks(net); - for (int i = 0; i < 50; i++) { - net.train(); - } + net.feedforward(); + //for (int i = 0; i < 50; i++) { + // net.train(); + //} auto end = std::chrono::high_resolution_clock::now(); net.list_net(); return std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count() / pow(10,9); diff --git a/src/bpnn.cpp b/src/bpnn.cpp @@ -162,6 +162,15 @@ void Network::feedforward() } } } + for (int i = 0; i < layers[length-1].contents->rows(); i++) { + float sum = 0; + for (int j = 0; j < layers[length-1].contents->cols(); j++) { + sum += exp((*layers[length-1].contents)(i,j)); + } + for (int j = 0; j < layers[length-1].contents->cols(); j++) { + (*layers[length-1].contents)(i,j) = exp((*layers[length-1].contents)(i,j))/sum; + } + } } void Network::list_net()