added feedForward and moving Reccurent neuron to normal
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
include ../Makefile.const
|
||||
|
||||
OBJFILES= ./sse_mathfun.o ./NeuralNetwork/Recurrent/Network.o ./NeuralNetwork/Recurrent/Neuron.o
|
||||
OBJFILES= ./sse_mathfun.o ./NeuralNetwork/Recurrent/Network.o ./NeuralNetwork/Neuron.o ./NeuralNetwork/FeedForward/Network.o ./NeuralNetwork/FeedForward/Layer.o
|
||||
|
||||
#LayerNetwork.o\
|
||||
# Learning/Learning.o Learning/BackPropagation.o ../sse_mathfun.o
|
||||
|
||||
10
src/NeuralNetwork/FeedForward/Layer.cpp
Normal file
10
src/NeuralNetwork/FeedForward/Layer.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <NeuralNetwork/FeedForward/Layer.h>
|
||||
|
||||
void NeuralNetwork::FeedForward::Layer::solve(const std::vector<float> &input, std::vector<float> &output) {
|
||||
output.resize(neurons.size());
|
||||
|
||||
for(auto &neuron:neurons) {
|
||||
output[neuron.id()]=neuron(input);
|
||||
}
|
||||
|
||||
}
|
||||
16
src/NeuralNetwork/FeedForward/Network.cpp
Normal file
16
src/NeuralNetwork/FeedForward/Network.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include <NeuralNetwork/FeedForward/Network.h>
|
||||
|
||||
std::vector<float> NeuralNetwork::FeedForward::Network::computeOutput(const std::vector<float>& input) {
|
||||
// this is here for simple swapping between input and output
|
||||
std::vector<float> partial1=input;
|
||||
std::vector<float> partial2;
|
||||
std::vector<float> *partialInputPtr = &partial1;
|
||||
std::vector<float> *partialOutputPtr = &partial2;
|
||||
|
||||
for(int i=1;i<layers.size();i++) {
|
||||
layers[i].solve(*partialInputPtr,*partialOutputPtr);
|
||||
std::swap(partialInputPtr,partialOutputPtr);
|
||||
}
|
||||
|
||||
return std::vector<float>(*partialInputPtr);
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
#include <NeuralNetwork/Recurrent/Neuron.h>
|
||||
#include <NeuralNetwork/Neuron.h>
|
||||
|
||||
std::string NeuralNetwork::Recurrent::Neuron::stringify(const std::string &prefix) const {
|
||||
std::string NeuralNetwork::Neuron::stringify(const std::string &prefix) const {
|
||||
std::ostringstream out;
|
||||
out.precision(std::numeric_limits<float>::digits10+1);
|
||||
|
||||
out << prefix << "{\n";
|
||||
out << prefix << "\t\"class\": \"NeuralNetwork::Recurrent::Neuron\",\n";
|
||||
out << prefix << "\t\"class\": \"NeuralNetwork::Neuron\",\n";
|
||||
out << prefix << "\t\"id\": " << id() << ",\n";
|
||||
out << prefix << "\t\"bias\": " << getBias() << ",\n";
|
||||
out << prefix << "\t\"output\": " << output() << ",\n";
|
||||
@@ -14,7 +14,7 @@ std::string NeuralNetwork::Recurrent::Neuron::stringify(const std::string &prefi
|
||||
out << prefix << "\t\"basisFunction\": " << basis->stringify() <<",\n";
|
||||
out << prefix << "\t\"weights\": {";
|
||||
bool first=true;
|
||||
for(size_t j=0;j<weights.size();j++) {
|
||||
for(std::size_t j=0;j<weights.size();j++) {
|
||||
if(weights[j]!= 0.0) {
|
||||
if(!first)
|
||||
out << ", ";
|
||||
Reference in New Issue
Block a user