Modified FeedForward to allow set activation to whole Layer and added XOR test for FF
This commit is contained in:
@@ -9,6 +9,8 @@
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace NeuralNetwork {
|
||||
namespace FeedForward {
|
||||
|
||||
@@ -29,24 +31,27 @@ namespace FeedForward {
|
||||
appendLayer(_inputSize);
|
||||
};
|
||||
|
||||
Layer& appendLayer(std::size_t size=1) {
|
||||
layers.push_back(Layer(size));
|
||||
|
||||
if(layers.size() > 1)
|
||||
layers.back().setInputSize(layers[layers.size()-2].size());
|
||||
|
||||
return layers.back();
|
||||
}
|
||||
|
||||
Layer& operator[](const std::size_t &id) {
|
||||
return layers[id];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Virtual destructor for Network
|
||||
*/
|
||||
virtual ~Network() {
|
||||
};
|
||||
for(auto &layer:layers) {
|
||||
delete layer;
|
||||
}
|
||||
}
|
||||
|
||||
Layer& appendLayer(std::size_t size=1, const ActivationFunction::ActivationFunction &activationFunction=ActivationFunction::Sigmoid(-4.9)) {
|
||||
layers.push_back(new Layer(size,activationFunction));
|
||||
|
||||
if(layers.size() > 1)
|
||||
layers.back()->setInputSize(layers[layers.size()-2]->size());
|
||||
|
||||
return *layers[layers.size()-1];//.back();
|
||||
}
|
||||
|
||||
Layer& operator[](const std::size_t &id) {
|
||||
return *layers[id];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This is a function to compute one iterations of network
|
||||
@@ -66,7 +71,7 @@ namespace FeedForward {
|
||||
if(!first) {
|
||||
out << ",";
|
||||
}
|
||||
out << layer;
|
||||
out << *layer;
|
||||
first=false;
|
||||
}
|
||||
out << "]";
|
||||
@@ -74,7 +79,7 @@ namespace FeedForward {
|
||||
}
|
||||
|
||||
protected:
|
||||
std::vector<Layer> layers;
|
||||
std::vector<Layer*> layers;
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user