jacobian

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

commit bec1678d6f27c9c4e89610fe91b9ffb363c837a1
parent dac772bf6ffacef14787fc5f3e028dd6f9f4a169
Author: David Freifeld <freifeld.david@gmail.com>
Date:   Tue, 30 Jun 2020 19:55:30 -0700

Some fixes, realized CNNs will be formidable

Uh oh more backprop

Diffstat:
Mcnn.cpp | 16++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/cnn.cpp b/cnn.cpp @@ -10,13 +10,14 @@ class ConvLayer Eigen::MatrixXd* output; public: + ConvLayer(int stride) void convolute(); }; void ConvLayer::convolute() { - for (int i = 0; i < input->cols() - kernel->cols() + 1; i++) { - for (int j = 0; j < input->rows() - kernel->rows() + 1; j++) { + for (int i = 0; i < input->cols() - kernel->cols() + 1; i+=stride_len) { + for (int j = 0; j < input->rows() - kernel->rows() + 1; j+=stride_len) { output(j, i) = (*kernel * input->block<kernel->rows(), kernel->cols()(j, i)).sum() } } @@ -36,8 +37,8 @@ void PoolingLayer::pool() { // It doesn't look like anything better than O(n^4) is doable for this as kernel needs to go through matrix and you need to index kernel. LOOK INTO ME!! float maxnum = -LARGE_NUM; - for (int i = 0; i < input->cols() - kernel->cols() + 1; i++) { - for (int j = 0; j < input->rows() - kernel->rows() + 1; j++) { + for (int i = 0; i < input->cols() - kernel->cols() + 1; i+=stride_len) { + for (int j = 0; j < input->rows() - kernel->rows() + 1; j+=stride_len) { for (int k = 0; k < kernel->cols(); k++) { for (int l = 0; l < kernel->rows(); l++) { if ((input->block<kernel->rows(), kernel->cols()(j, i))(l, k) > maxnum) { @@ -52,18 +53,21 @@ void PoolingLayer::pool() class ConvNet : Network { int stride_len; + int preprocess_length; std::vector<ConvLayer> conv_layers; std::vector<PoolingLayer> pool_layers; public: ConvNet(char* path, int batch_sz, float learn_rate, float bias_rate); + void process(); // Runs the convolutional and pooling layers. + void next_batch(); + void add_conv_layer(); }; -ConvNet::ConvNet(char* path, int batch_sz, float learn_rate, float bias_rate, int stride) +ConvNet::ConvNet(char* path, int batch_sz, float learn_rate, float bias_rate) { learning_rate = learn_rate; bias_lr = bias_rate; - stride_len = stride; instances = prep_file(path, "./shuffled.txt"); length = 0; t = 0;