Guest User

Untitled

a guest
Sep 29th, 2016
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1. #ifndef MLP_H
  2. #define MLP_H
  3.  
  4.   #include <stdlib.h>
  5.   #include <unistd.h>
  6.   #include <algorithm>
  7.   #include <vector>
  8.   #include <ctime>
  9.   #include <iterator>
  10.   #include <cmath>
  11.  
  12.   #define sigmoid(value)  (1/(1+exp(-value)));
  13.   #define dersigmoid(value) (value*(1-value));
  14.  
  15.  
  16.   //Macro's
  17.  
  18.   #define weightItoH(input,hidden) weightsIH.at(nInput*hidden+input)
  19.   #define weightHtoO(hidden,output) weightsHO.at(nHidden*output+hidden)
  20.  
  21.   class MLP {
  22.  
  23.     public:
  24.       std::vector<int> inputNeurons;
  25.       std::vector<float> hiddenNeurons;
  26.       std::vector<float> outputNeurons;
  27.       std::vector<float> weightsIH;
  28.       std::vector<float> weightsHO;
  29.       std::vector< std::vector<int> > inputPatterns;
  30.       std::vector<int> desiredOutput;
  31.       std::vector<float> outputDelta;
  32.       std::vector<float> hiddenDelta;
  33.  
  34.       int nInput;
  35.       int nOutput;
  36.       int nHidden;
  37.       int nInputPatterns;
  38.       int inPutPatterns;
  39.  
  40.       MLP (int nInput, int nHidden, int nOutput);
  41.       ~MLP();
  42.  
  43.       void initWeights();
  44.       void printWeights(int i);
  45.       void feedforward();
  46.       void initInput(int i, int j);
  47.       void backPropagation(int i);
  48.       void trainNetwork();
  49.  
  50.   };
  51.  
  52.  
  53.  
  54. #endif
Add Comment
Please, Sign In to add comment