// Copyright (C) 2001 Jean-Marc Valin #ifndef FFLAYER_H #define FFLAYER_H #include "Object.h" #include #include #include #include "functions.h" namespace FD { /**Represents one (fully-connected) layer from a multi-layer percetron (FFNet) @author: Jean-Marc Valin */ class FFLayer : public Object { public: /**Activation function pointer*/ void (*func) (float *, float *, int); /**Activation function derivative pointer*/ void (*deriv_func) (float *, float *, int); protected: /**Number of neurons in the layer*/ int nbNeurons; /**Number of input neurons*/ int nbInputs; /**Pointer to the weight vector*/ float *weights; /*type of activation function (tansig, sigmoid, lin)*/ std::string funcType; /**Offset of the layer weight vector in the network weight vector*/ int weightOffset; /**Offset of the layer's first neuron in the list of all network neurons (not too sure about that one, though)*/ int neuronOffset; /**Offset of the layer's first neuron derivative in the list of all network neurons*/ float derivOffset; public: /**This (empty) constructor is used for parsing a layer from a file*/ FFLayer() : derivOffset(0) {} //FFLayer(float *_weights) : weights(_weights) {}; /**Standard constructor*/ FFLayer(int _nbNeurons, int _nbInputs, float *_weights, int _weightOffset, int _neuronOffset, std::string type = "tansig"); /**Unimplemented yet (not sure if we *should* implement it)*/ FFLayer(const FFLayer &layer) {std::cerr << "I wouldn't do that if I were you\n";} /**Called after reading a layer to setup the weight vector correctly*/ void setupAfterRead(float *_weights, int _weightOffset, int _neuronOffset); ~FFLayer() { } /**Calculates all the activation functions (and derivatives) for a given input*/ void update(const float *previous, float *value, float *deriv=NULL) { for (int i=0;i> (std::istream &in, FFLayer &layer); }//namespace FD #endif