PetaVision  Alpha
InitRandomWeights.hpp
1 /*
2  * InitRandomWeights.hpp
3  *
4  * Created on: Aug 21, 2013
5  * Author: pschultz
6  */
7 
8 #ifndef INITRANDOMWEIGHTS_HPP_
9 #define INITRANDOMWEIGHTS_HPP_
10 
11 #include "InitWeights.hpp"
12 #include "columns/Random.hpp"
13 
14 namespace PV {
15 
17  public:
18  // No public constructor, as this is a purely virtual class.
19  virtual ~InitRandomWeights();
20 
21  protected:
23  int initialize(char const *name, HyPerCol *hc);
24  virtual int initRNGs(bool isKernel) override;
25  virtual void calcWeights(int patchIndex, int arborId) override;
26  virtual void randomWeights(float *patchDataStart, int patchIndex) = 0;
27  // Subclasses must implement randomWeights.
28  // patchDataStart is a pointer to the beginning of a data patch.
29  // patchIndex is the index for that patch. The RNGs are accessed by calling randState's get
30  // method; or random numbers are generated directly by calling randState methods.
31  // The method should fill the entire patch (the dimensions are in weightParams) regardless of
32  // whether the patch is shrunken.
33  // This means that weights on different MPI processes that represent the same physical synapse
34  // will have the same weight.
35 
36  // Data members
37  protected:
38  Random *mRandState = nullptr;
39  // For HyPerConns, there will be an RNG for each presynaptic extended neuron.
40  // In MPI, if a presynaptic neuron is represented on more than one process, its RNG should be
41  // in the same state in each of these processes.
42  // initRNGs handles that by using the presynaptic global extended index to seed the RNG.
43  //
44  // For KernelConns, there will be an RNG for each data patch.
45  // In MPI, the a given data patch should be in the same state across all MPI processes.
46  // initRNGs handles that by using the data patch to seed the RNG.
47 
48 }; /* class InitRandomWeights */
49 
50 } /* namespace PV */
51 #endif /* INITRANDOMWEIGHTS_HPP_ */
virtual void calcWeights()