PetaVision  Alpha
NormalizeMultiply.hpp
1 /*
2  * NormalizeMultiply.hpp
3  *
4  * Created on: Oct 24, 2014
5  * Author: pschultz
6  */
7 
8 #ifndef NORMALIZEMULTIPLY_HPP_
9 #define NORMALIZEMULTIPLY_HPP_
10 
11 #include "NormalizeBase.hpp"
12 #include "components/Weights.hpp"
13 
14 namespace PV {
15 
17  // Member functions
18  protected:
28  virtual void ioParam_rMinX(enum ParamsIOFlag ioFlag);
29 
33  virtual void ioParam_rMinY(enum ParamsIOFlag ioFlag);
34 
38  virtual void ioParam_nonnegativeConstraintFlag(enum ParamsIOFlag ioFlag);
39 
46  virtual void ioParam_normalize_cutoff(enum ParamsIOFlag ioFlag);
47 
55  virtual void ioParam_normalizeFromPostPerspective(enum ParamsIOFlag ioFlag);
56  // If false, group all weights with a common presynaptic
57  // neuron for normalizing. If true, group all weights with a
58  // common postsynaptic neuron
59  // Only meaningful (at least for now) for KernelConns using sum of weights or sum of squares
60  // normalization methods.
61  // end of NormalizeMultiply parameters
63 
64  public:
65  NormalizeMultiply(const char *name, HyPerCol *hc);
66  virtual ~NormalizeMultiply();
67 
68  float getRMinX() { return mRMinX; }
69  float getRMinY() { return mRMinY; }
70  float getNormalizeCutoff() { return mNormalizeCutoff; }
71  bool getNormalizeFromPostPerspectiveFlag() { return mNormalizeFromPostPerspective; }
72 
73  virtual int normalizeWeights() override;
74 
75  protected:
77  int initialize(const char *name, HyPerCol *hc);
78 
79  virtual int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override;
80 
81  int applyThreshold(
82  float *dataPatchStart,
83  int weights_in_patch,
84  float wMax); // weights less than normalize_cutoff*max(weights) are zeroed out
85 
97  int applyRMin(
98  float *dataPatchStart,
99  float rMinX,
100  float rMinY,
101  int nxp,
102  int nyp,
103  int xPatchStride,
104  int yPatchStride);
105 
106  static void normalizePatch(float *patchData, int weightsPerPatch, float multiplier);
107 
108  // Member variables
109  protected:
110  float mRMinX = 0.0f;
111  float mRMinY = 0.0f;
112  bool mNonnegativeConstraintFlag = false;
113  float mNormalizeCutoff = 0.0f;
114  bool mNormalizeFromPostPerspective = false;
115 }; // class NormalizeMultiply
116 
117 } /* namespace PV */
118 
119 #endif /* NORMALIZEMULTIPLY_HPP_ */
virtual int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override
virtual void ioParam_nonnegativeConstraintFlag(enum ParamsIOFlag ioFlag)
int applyRMin(float *dataPatchStart, float rMinX, float rMinY, int nxp, int nyp, int xPatchStride, int yPatchStride)
virtual void ioParam_normalize_cutoff(enum ParamsIOFlag ioFlag)
virtual void ioParam_normalizeFromPostPerspective(enum ParamsIOFlag ioFlag)
virtual void ioParam_rMinX(enum ParamsIOFlag ioFlag)
virtual void ioParam_rMinY(enum ParamsIOFlag ioFlag)
int applyThreshold(float *dataPatchStart, int weights_in_patch, float wMax)