#include #include #include "layer.h" #include "neuron.h" #include "connection.h" #include "activation.h" //Layer::Layer() : Layer::Layer() // index(-1), // neurons(10) // index(0) //neurons(10) { //idx++; //index++; index = -1; neurons.reserve(10); //neurons = std::vector(); //std::cout << "neurons size: " << neurons.size() << std::endl; } Layer::Layer(unsigned int num_neurons) { index = -1; neurons.reserve(num_neurons); for (unsigned int i = 0; isetIndex(i); neurons.push_back(tmp); } /* // Add a bias neuron in each layer. // Force the bias node's output to 1.0 (it was the last neuron pushed in this layer): pNeuronX tmp(new Neuron()); tmp->setIndex(100); tmp->setValue(1); neurons.push_back(tmp); //neurons.back().back().setOutputVal(1.0); //neurons.back()->setValue(1.0); */ } int Layer::getIndex(void) { return index; } void Layer::setIndex(const int& index) { this->index = index; } unsigned int Layer::getSize(void) { return neurons.size(); } void Layer::addNeuron(const pNeuronX& n) { neurons.push_back(n); } void Layer::removeNeuron(const int& idx) { assert(neurons.size() >= idx); for (unsigned i = neurons.size()-1; i > 0; i--) { if (neurons[i]->getIndex() == idx) { neurons.erase(neurons.begin() + i); return; } } } pNeuronX &Layer::getNeuron(const int& idx) { assert(neurons.size() >= idx); return neurons[idx]; } void Layer::feedForward(const pLayerX& prevLayer) { /* // INPUT -> HIDDEN for(y=0; y