You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.8 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __GRU_LAYER_HEADERS__
  2. #define __GRU_LAYER_HEADERS__
  3. //#include "activations.h"
  4. //#include "layer.h"
  5. //#include "network.h"
  6. #include "../base/basicLayer.h"
  7. #include "connectedLayer.h"
  8. class gruLayer : public cortexLayer{
  9. private:
  10. void increment(connectedLayer * tPtr, int steps);
  11. connectedLayer * inputZLayer;
  12. connectedLayer * inputRLayer;
  13. connectedLayer * inputHLayer;
  14. connectedLayer * stateZLayer;
  15. connectedLayer * stateRLayer;
  16. connectedLayer * stateHLayer;
  17. float * m_pState;
  18. float * m_pPrevState;
  19. float * m_pForgotState;
  20. float * m_pForgotDelta;
  21. float * m_pR;
  22. float * m_pZ;
  23. float * m_pH;
  24. #ifdef GPU
  25. float * m_pGpuState;
  26. float * m_pGpuPrevState;
  27. float * m_pGpuForgotState;
  28. float * m_pGpuForgotDelta;
  29. float * m_pGpuR;
  30. float * m_pGpuZ;
  31. float * m_pGpuH;
  32. #endif
  33. public:
  34. explicit gruLayer(bool useGPU = true);
  35. virtual ~gruLayer();
  36. bool create( uint32_t batch, uint32_t inputs, uint32_t outputs, uint32_t steps, bool batch_normalize);
  37. virtual void forward( cortexSTATE state);
  38. virtual void backward( cortexSTATE state);
  39. virtual void loadWeights(FILE * Ptr, bool trans = false);
  40. virtual void update( uint32_t batch, float learning_rate, float momentum, float decay);
  41. friend class gpuCUDA;
  42. friend class cpuHOST;
  43. };
  44. /*
  45. void forward_gru_layer(layer l, network_state state);
  46. void backward_gru_layer(layer l, network_state state);
  47. void update_gru_layer(layer l, int batch, float learning_rate, float momentum, float decay);
  48. #ifdef GPU
  49. void forward_gru_layer_gpu(layer l, network_state state);
  50. void backward_gru_layer_gpu(layer l, network_state state);
  51. void update_gru_layer_gpu(layer l, int batch, float learning_rate, float momentum, float decay);
  52. void push_gru_layer(layer l);
  53. void pull_gru_layer(layer l);
  54. #endif
  55. */
  56. #endif