/* * file : backprop.h * * User-defined parameters for backprop. * */ class BackPropHiddenLayer : public NslModule { public: NslDinFloat1 bInput; NslDinFloat1 fInput; NslDoutFloat1 mf; protected: NslFloat1 mp; NslFloat1 delta; NslFloat1 h; // Threshold NslFloat1 dh; // Change in threshold NslFloat2 w; NslFloat2 dw; NslFloat0 lrate; NslFloat0 momentum; public: BackPropHiddenLayer(char*,NslModule*); ~BackPropHiddenLayer() {} void memAlloc(int,int); void forwardPass(); void backwardPass(); void calculateDelta(); void updateWeights(); void updateThresholds(); void initSys(); void initTrain(); void endTrain(); }; class BackPropOutputLayer : public BackPropHiddenLayer { public: NslDoutFloat1 bOutput; public: BackPropOutputLayer(char*,NslModule*); ~BackPropOutputLayer() {} void memAlloc(int,int); void backwardPass(); void propagateError(); }; class BackPropLayers : public NslModule { public: BackPropHiddenLayer hl; BackPropOutputLayer ol; NslDinFloat1 input; NslDinFloat1 desired; NslDoutFloat1 output; NslDoutFloat1 eOutput; private: NslFloat0 stopError; NslFloat0 pss; NslFloat0 tss; public: BackPropLayers(char*,NslModule*); ~BackPropLayers() {} void memAlloc(int,int,int); void initModule(); void calculateError(); void initSys(); void initTrain(); void simTrain(); void endTrain(); void simRun(); }; class TrainManager : public NslModule { NslFloat2 pInput; NslFloat2 pOutput; NslInt0 numPats; nsl_str_data fname; public: NslDoutFloat1 dInput; NslDoutFloat1 dOutput; TrainManager(char*,NslModule*); ~TrainManager() {} void readFile(int,int); void memAlloc(int,int,int); void simTrain(); }; class BackPropModel : public NslModel { TrainManager tf; BackPropLayers bp; NslInt0 inSize; NslInt0 hidSize; NslInt0 outSize; public: BackPropModel(); ~BackPropModel() {} void makeConn(); void initSys(); };