summaryrefslogtreecommitdiff
path: root/src/CuTNetLib/.svn/text-base/cuDiscreteLinearity.h.svn-base
blob: 06c8d7442f97453e64b3a31f9cb935550aadfa8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#ifndef _CUDISCRETE_LINEARITY_H_
#define _CUDISCRETE_LINEARITY_H_


#include "cuComponent.h"
#include "cumatrix.h"


#include "Matrix.h"
#include "Vector.h"

#include <vector>


namespace TNet {

  class CuDiscreteLinearity : public CuUpdatableComponent
  {
    public:

      CuDiscreteLinearity(size_t nInputs, size_t nOutputs, CuComponent *pPred); 
      ~CuDiscreteLinearity();  
      
      ComponentType GetType() const;
      const char* GetName() const;

      void PropagateFnc(const CuMatrix<BaseFloat>& X, CuMatrix<BaseFloat>& Y);
      void BackpropagateFnc(const CuMatrix<BaseFloat>& X, CuMatrix<BaseFloat>& Y);

      void Update();

      void ReadFromStream(std::istream& rIn);
      void WriteToStream(std::ostream& rOut);

    protected:
      std::vector<CuMatrix<BaseFloat> > mLinearity;  ///< Matrix with neuron weights
      CuVector<BaseFloat> mBias;       ///< Vector with biases

      std::vector<CuMatrix<BaseFloat> > mLinearityCorrection; ///< Matrix for linearity updates
      CuVector<BaseFloat> mBiasCorrection;      ///< Vector for bias updates

      size_t mNBlocks;

  };




  ////////////////////////////////////////////////////////////////////////////
  // INLINE FUNCTIONS 
  // CuDiscreteLinearity::
  inline 
  CuDiscreteLinearity::
  CuDiscreteLinearity(size_t nInputs, size_t nOutputs, CuComponent *pPred)
    : CuUpdatableComponent(nInputs, nOutputs, pPred), 
      //mLinearity(nInputs,nOutputs), mBias(nOutputs),
      //mLinearityCorrection(nInputs,nOutputs), mBiasCorrection(nOutputs)
      mNBlocks(0)
  { 
    //mLinearityCorrection.SetConst(0.0);
    //mBiasCorrection.SetConst(0.0);
  }


  inline
  CuDiscreteLinearity::
  ~CuDiscreteLinearity()
  { }

  inline CuComponent::ComponentType
  CuDiscreteLinearity::
  GetType() const
  {
    return CuComponent::DISCRETE_LINEARITY;
  }

  inline const char*
  CuDiscreteLinearity::
  GetName() const
  {
    return "<discretelinearity>";
  }



} //namespace



#endif