Skip to content

Commit

Permalink
Corrected Layer file and added NeuralNetwork file
Browse files Browse the repository at this point in the history
  • Loading branch information
riktimmondal committed Feb 5, 2020
1 parent c813373 commit 0583222
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 3 deletions.
6 changes: 3 additions & 3 deletions openann/include/Layer.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef _LAYER_HPP_
#define _LAYER_HPP_
#ifndef _LAYER_
#define _LAYER_

#include <iostream>
#include <vector>
Expand All @@ -23,4 +23,4 @@ class Layer
vector<Neuron *> neurons;
};

#endif
#endif
24 changes: 24 additions & 0 deletions openann/include/NeuralNetwork.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef _NEURALNETWORK_
#define _NEURALNETWORK_

#include <iostream>
#include "Matrix.hpp"
#include "Layer.hpp"
#include <vector>

using namespace std;

class NeuralNetwork {
public:
NeuralNetwork(vector<int> topology);
void setCurrentInput(vector<double> input);

private:
int topologySize;
vector<int> topology;
vector<Layer *> layers;
vector<Matrix *> weightMatrices;
vector<double> input;
};

#endif
24 changes: 24 additions & 0 deletions openann/src/NeuralNetwork.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "../include/NeuralNetwork.hpp"

NeuralNetwork::NeuralNetwork(vector<int> topology) {
this->topology = topology;
this->topologySize = topology.size();

for(int i=0;i<topologySize;i++){
Layer *l = new Layer(topology.at(i));
this->layers.push_back(l);
}

for(int i=0;i< (topologySize-1);i++){
Matrix *m = new Matrix(topology.at(i), topology.at(i+1), true);
this->weightMatrices.push_back(m);
}
}

void NeuralNetwork::setCurrentInput(vector<double> input) {
this->input = input;

for(int i=0;i<input.size();i++) {
this->layers.at(0)->setVal(i, input.at(i));
}
}

0 comments on commit 0583222

Please sign in to comment.