/************************************************************************************************** * LibNeural++ v.0.2 - All-purpose library for managing neural networks * * Copyright (C) 2009, BlackLight * * * * This program is free software: you can redistribute it and/or modify it under the terms of the * * GNU General Public License as published by the Free Software Foundation, either version 3 of * * the License, or (at your option) any later version. This program is distributed in the hope * * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * * more details. You should have received a copy of the GNU General Public License along with * * this program. If not, see . * **************************************************************************************************/ #include #include "neural++.hpp" using namespace neuralpp; /** * @brief Constructor * @param sz Size of the layer * @param a Activation function * @param d Its derivate */ Layer::Layer (size_t sz, double(*a)(double), double(*d)(double)) { for (size_t i=0; i &el, double (*a)(double), double(*d)(double)) { elements=el; actv_f=a; deriv=d; } /** * @return Number of neurons in the layer */ size_t Layer::size() { return elements.size(); } /** * @brief Redefinition for operator []. It gets the neuron at i */ Neuron& Layer::operator[] (size_t i) { return elements[i]; } /** * @brief It links a layer to another * @param l Layer to connect to the current as input layer */ void Layer::link (Layer& l) { srand ((unsigned) time(NULL)); for (size_t i=0; ipush_out(s); n2->push_in(s); } } } /** * @brief It sets a vector of propagation values to all its neurons * @param v Vector of values to write as propagation values */ void Layer::setProp (vector &v) { for (size_t i=0; i &v) { for (size_t i=0; isetProp(n->propagate()); n->setActv( actv_f(n->getProp()) ); } }