PetaVision  Alpha
PV::MomentumUpdater Class Reference
Inheritance diagram for PV::MomentumUpdater:
PV::HebbianUpdater PV::BaseWeightUpdater PV::BaseObject PV::CheckpointerDataInterface PV::Observer

BaseWeightUpdater Parameters

List of parameters needed from the BaseWeightUpdater class

virtual void ioParam_plasticityFlag (enum ParamsIOFlag ioFlag)
 plasticityFlag: Specifies if the weights will update
 

HebbianUpdater Parameters

List of parameters needed from the HebbianUpdater class

virtual void ioParam_triggerLayerName (enum ParamsIOFlag ioFlag)
 
virtual void ioParam_triggerOffset (enum ParamsIOFlag ioFlag)
 
virtual void ioParam_weightUpdatePeriod (enum ParamsIOFlag ioFlag)
 
virtual void ioParam_initialWeightUpdateTime (enum ParamsIOFlag ioFlag)
 
virtual void ioParam_immediateWeightUpdate (enum ParamsIOFlag ioFlag)
 
virtual void ioParam_dWMax (enum ParamsIOFlag ioFlag)
 
virtual void ioParam_dWMaxDecayInterval (enum ParamsIOFlag ioFlag)
 
virtual void ioParam_dWMaxDecayFactor (enum ParamsIOFlag ioFlag)
 
virtual void ioParam_normalizeDw (enum ParamsIOFlag ioFlag)
 
virtual void ioParam_useMask (enum ParamsIOFlag ioFlag)
 
virtual void ioParam_combine_dW_with_W_flag (enum ParamsIOFlag ioFlag)
 

MomentumUpdater Parameters

List of parameters needed from the MomentumUpdater class

virtual void ioParam_momentumMethod (enum ParamsIOFlag ioFlag)
 momentumMethod: Controls the interpretation of the timeConstantTau and momentumDelay parameters.
 
virtual void ioParam_timeConstantTau (enum ParamsIOFlag ioFlag)
 timeConstantTau: controls the amount of momentum in weight updates. More...
 
virtual void ioParam_momentumTau (enum ParamsIOFlag ioFlag)
 momentumTau: controls the amount of momentum in weight updates. Deprecated in favor of timeConstantTau. More...
 
virtual void ioParam_momentumDecay (enum ParamsIOFlag ioFlag)
 

Public Member Functions

 MomentumUpdater (char const *name, HyPerCol *hc)
 
void addClone (ConnectionData *connectionData)
 
bool getDataStructuresAllocatedFlag () const
 
float const * getDeltaWeightsDataHead (int arborId, int dataIndex) const
 
float const * getDeltaWeightsDataStart (int arborId) const
 
std::string const & getDescription () const
 
char const * getDescription_c () const
 
bool getInitialValuesSetFlag () const
 
bool getInitInfoCommunicatedFlag () const
 
char const * getMomentumMethod ()
 
MPIBlock const * getMPIBlock ()
 
char const * getName () const
 
std::string const & getObjectType () const
 
bool getPlasticityFlag () const
 
float getTimeConstantTau () const
 
void ioParams (enum ParamsIOFlag ioFlag, bool printHeader, bool printFooter)
 
bool isUsingDeprecatedMomentumTau () const
 
bool isUsingGPU () const
 
char const * lookupKeyword () const
 
void readParams ()
 
virtual Response::Status respond (std::shared_ptr< BaseMessage const > message) override
 
void writeParams ()
 

Static Public Attributes

static constexpr float mDefaultTimeConstantTauAlex = 0.9f
 
static constexpr float mDefaultTimeConstantTauSimple = 0.25f
 
static constexpr float mDefaultTimeConstantTauViscosity = 100.0f
 

Protected Types

enum  Method { UNDEFINED_METHOD, VISCOSITY, SIMPLE, ALEX }
 

Protected Member Functions

virtual Response::Status allocateDataStructures () override
 
void applyMomentum (int arborId)
 
void applyMomentum (int arborId, float dwFactor, float wFactor)
 
void applyMomentumDeprecated (int arborId)
 
void applyMomentumDeprecated (int arborId, float dwFactor, float wFactor)
 
void blockingNormalize_dW ()
 
void checkTimeConstantTau ()
 
virtual Response::Status cleanup () override
 
int clear_dW (int arborId)
 
int clearNumActivations (int arborId)
 
virtual Response::Status communicateInitInfo (std::shared_ptr< CommunicateInitInfoMessage const > message) override
 
virtual void computeNewWeightUpdateTime (double time, double currentUpdateTime)
 
virtual Response::Status copyInitialStateToGPU ()
 
void decay_dWMax ()
 
int initialize (char const *name, HyPerCol *hc)
 
int initialize_dW (int arborId)
 
virtual Response::Status initializeState ()
 
virtual int ioParamsFillGroup (enum ParamsIOFlag ioFlag) override
 
virtual bool needUpdate (double time, double dt)
 
virtual void normalize_dW ()
 
virtual int normalize_dW (int arbor_ID)
 
virtual Response::Status prepareCheckpointWrite () override
 
virtual Response::Status processCheckpointRead ()
 
virtual Response::Status readStateFromCheckpoint (Checkpointer *checkpointer) override
 
void reduce_dW ()
 
virtual int reduce_dW (int arborId)
 
void reduceAcrossBatch (int arborID)
 
virtual int reduceActivations (int arborID)
 
virtual int reduceKernels (int arborID)
 
virtual Response::Status registerData (Checkpointer *checkpointer) override
 
Response::Status respondAllocateData (std::shared_ptr< AllocateDataMessage const > message)
 
Response::Status respondCleanup (std::shared_ptr< CleanupMessage const > message)
 
Response::Status respondCommunicateInitInfo (std::shared_ptr< CommunicateInitInfoMessage const > message)
 
Response::Status respondCopyInitialStateToGPU (std::shared_ptr< CopyInitialStateToGPUMessage const > message)
 
Response::Status respondInitializeState (std::shared_ptr< InitializeStateMessage const > message)
 
Response::Status respondPrepareCheckpointWrite (std::shared_ptr< PrepareCheckpointWriteMessage const > message)
 
Response::Status respondProcessCheckpointRead (std::shared_ptr< ProcessCheckpointReadMessage const > message)
 
Response::Status respondReadStateFromCheckpoint (std::shared_ptr< ReadStateFromCheckpointMessage< Checkpointer > const > message)
 
Response::Status respondRegisterData (std::shared_ptr< RegisterDataMessage< Checkpointer > const > message)
 
Response::Status respondSetCudaDevice (std::shared_ptr< SetCudaDeviceMessage const > message)
 
virtual Response::Status setCudaDevice (std::shared_ptr< SetCudaDeviceMessage const > message)
 
void setDataStructuresAllocatedFlag ()
 
void setDescription ()
 
void setInitialValuesSetFlag ()
 
void setInitInfoCommunicatedFlag ()
 
int setName (char const *name)
 
virtual void setObjectType () override
 
int setParent (HyPerCol *hc)
 
int update_dW (int arborID)
 
void updateArbors ()
 
void updateInd_dW (int arborID, int batchID, float const *preLayerData, float const *postLayerData, int kExt)
 
void updateLocal_dW ()
 
virtual float updateRule_dW (float pre, float post)
 
virtual void updateState (double timestamp, double dt) override
 
virtual int updateWeights (int arborId) override
 
void updateWeightsDelayed (double simTime, double dt)
 
void updateWeightsImmediate (double simTime, double dt)
 
void wait_dWReduceRequests ()
 

Protected Attributes

std::string description
 
ArborListmArborList = nullptr
 
std::vector< ConnectionData * > mClones
 
bool mCombine_dWWithWFlag = false
 
ConnectionDatamConnectionData = nullptr
 
PVCuda::CudaDevice * mCudaDevice = nullptr
 
bool mDataStructuresAllocatedFlag = false
 
WeightsmDeltaWeights = nullptr
 
std::vector< MPI_Request > mDeltaWeightsReduceRequests
 
float mDWMax = std::numeric_limits<float>::quiet_NaN()
 
int mDWMaxDecayFactor = 0
 
float mDWMaxDecayInterval = 0.0f
 
int mDWMaxDecayTimer = 0
 
bool mImmediateWeightUpdate = true
 
bool mInitializeFromCheckpointFlag = false
 
bool mInitialValuesSetFlag = false
 
double mInitialWeightUpdateTime = 0.0
 
bool mInitInfoCommunicatedFlag = false
 
double mLastTimeUpdateCalled = 0.0
 
double mLastUpdateTime = 0.0
 
Method mMethod = UNDEFINED_METHOD
 
float mMomentumDecay = 0.0f
 
char * mMomentumMethod = nullptr
 
float mMomentumTau = 0.25f
 
bool mNeedFinalize = true
 
bool mNormalizeDw = true
 
long ** mNumKernelActivations = nullptr
 
std::string mObjectType
 
bool mPlasticityFlag = true
 
WeightsmPrevDeltaWeights = nullptr
 
bool mReductionPending = false
 
float mTimeConstantTau = mDefaultTimeConstantTauViscosity
 
bool mTriggerFlag = false
 
HyPerLayermTriggerLayer = nullptr
 
char * mTriggerLayerName = nullptr
 
double mTriggerOffset = 0.0
 
bool mUsingDeprecatedMomentumTau = false
 
bool mUsingGPUFlag = false
 
WeightsmWeights = nullptr
 
double mWeightUpdatePeriod = 0.0
 
double mWeightUpdateTime = 0.0
 
bool mWriteCompressedCheckpoints = false
 
char * name = nullptr
 
HyPerColparent = nullptr
 

Detailed Description

Definition at line 15 of file MomentumUpdater.hpp.

Member Function Documentation

void PV::HebbianUpdater::decay_dWMax ( )
protectedinherited

Decrements the counter for dWMaxDecayInterval, and if at the end of the interval, decays the dWMax value.

Definition at line 858 of file HebbianUpdater.cpp.

bool PV::BaseObject::getDataStructuresAllocatedFlag ( ) const
inlineinherited

Get-method for mDataStructuresAllocatedFlag, which is false on initialization and then becomes true once setDataStructuresAllocatedFlag() is called.

Definition at line 102 of file BaseObject.hpp.

bool PV::BaseObject::getInitialValuesSetFlag ( ) const
inlineinherited

Get-method for mInitialValuesSetFlag, which is false on initialization and then becomes true once setInitialValuesSetFlag() is called.

Definition at line 108 of file BaseObject.hpp.

bool PV::BaseObject::getInitInfoCommunicatedFlag ( ) const
inlineinherited

Get-method for mInitInfoCommunicatedFlag, which is false on initialization and then becomes true once setInitInfoCommunicatedFlag() is called.

Definition at line 95 of file BaseObject.hpp.

void PV::MomentumUpdater::ioParam_momentumDecay ( enum ParamsIOFlag  ioFlag)
protectedvirtual

momentumDecay: The decay rate on the weights, * applied after the momentum weight updates.

Definition at line 126 of file MomentumUpdater.cpp.

void PV::MomentumUpdater::ioParam_momentumTau ( enum ParamsIOFlag  ioFlag)
protectedvirtual

momentumTau: controls the amount of momentum in weight updates. Deprecated in favor of timeConstantTau.

If timeConstantTau is not in params and momentumTau is, the update rule is as follows.

For momentumMethod = "simple", the update rule is

dW = dW_Hebb + momentumTau * dWprev - momentumDecay * W.

where dW_Hebb = dWMax * pre * post.

For momentumMethod = "viscosity", the update rule is the same as for "simple", except that momentumTau is replaced by exp(-1/momentumTau).

For momentumMethod = "alex", the update rule is

dW = dW_Hebb + momentumTau * dWprev = momentumTau * dWMax * W.

Definition at line 105 of file MomentumUpdater.cpp.

void PV::MomentumUpdater::ioParam_timeConstantTau ( enum ParamsIOFlag  ioFlag)
protectedvirtual

timeConstantTau: controls the amount of momentum in weight updates.

For momentumMethod = "viscosity", the update rule is

dW = (1-tauFactor) * dW_Hebb + tauFactor * dWprev - momentumDecay * W.

where dW_Hebb = dWMax * pre * post and tauFactor = exp(-1/timeConstantTau). The interpretation is that for the impulse from a single pre*post event, the weight approaches the value dW_Hebb as t->infinity, and that timeConstantTau indicates the rate of decay of W - dW_Hebb, measured in weightUpdatePeriods

For momentumMethod = "simple", the update rule is the same as for "viscosity", except that tauFactor = timeConstantTau.

For momentumMethod = "alex", the update rule is

dW = ((1-timeConstantTau) * dW_Hebb + timeConstantTau * dWprev) - momentumDecay * dWMax * W,

For momentumMethod = "simple" or "alex", 0 <= timeConstantTau < 1 is required. For momentumMethod = "viscosity", timeConstantTau >= 0 is required.

Definition at line 50 of file MomentumUpdater.cpp.

void PV::BaseObject::ioParams ( enum ParamsIOFlag  ioFlag,
bool  printHeader,
bool  printFooter 
)
inherited

Method for reading or writing the params from group in the parent HyPerCol's parameters. The group from params is selected using the name of the connection.

If ioFlag is set to write, the printHeader and printFooter flags control whether a header and footer for the parameter group is produces. These flags are set to true for layers, connections, and probes; and set to false for weight initializers and normalizers. If ioFlag is set to read, the printHeader and printFooter flags are ignored.

Note that ioParams is not virtual. To add parameters in a derived class, override ioParamFillGroup.

Definition at line 74 of file BaseObject.cpp.

int PV::MomentumUpdater::ioParamsFillGroup ( enum ParamsIOFlag  ioFlag)
overrideprotectedvirtual

The virtual method for reading parameters from the parent HyPerCol's parameters, and writing to the output params file.

Derived classes with additional parameters typically override ioParamsFillGroup to call the base class's ioParamsFillGroup method and then call ioParam_[parametername] for each of their parameters. The ioParam_[parametername] methods should call the parent HyPerCol's ioParamValue() and related methods, to ensure that all parameters that get read also get written to the outputParams-generated file.

Reimplemented from PV::HebbianUpdater.

Definition at line 21 of file MomentumUpdater.cpp.

bool PV::BaseObject::isUsingGPU ( ) const
inlineinherited

Returns true if the object requires the GPU; false otherwise. HyPerCol will not initialize the GPU unless one of the objects in its hierarchy returns true

Definition at line 116 of file BaseObject.hpp.

char const * PV::BaseObject::lookupKeyword ( ) const
inherited

Look up the keyword of the params group with the same name as the object.

Definition at line 42 of file BaseObject.cpp.

void PV::BaseObject::readParams ( )
inlineinherited

A method that reads the parameters for the group whose name matches the name of the object. It, along with writeParams(), is a wrapper around ioParams, so that readParams and writeParams automatically run through the same parameters in the same order.

Definition at line 62 of file BaseObject.hpp.

void PV::BaseObject::setDataStructuresAllocatedFlag ( )
inlineprotectedinherited

This method sets mDataStructuresAllocatedFlag to true.

Definition at line 175 of file BaseObject.hpp.

void PV::BaseObject::setInitialValuesSetFlag ( )
inlineprotectedinherited

This method sets the flag returned by getInitialValuesSetFlag to true.

Definition at line 180 of file BaseObject.hpp.

void PV::BaseObject::setInitInfoCommunicatedFlag ( )
inlineprotectedinherited

This method sets mInitInfoCommunicatedFlag to true.

Definition at line 170 of file BaseObject.hpp.

void PV::HebbianUpdater::updateLocal_dW ( )
protectedinherited

updateLocal_dW computes the contribution of the current process to dW, before MPI reduction and normalization. The routine calls initialize_dW for each arbor, and then updateWeights for each arbor.

Definition at line 422 of file HebbianUpdater.cpp.

void PV::BaseObject::writeParams ( )
inlineinherited

A method that writes the parameters for the group whose name matches the name of the object. It, along with readParams(), is a wrapper around ioParams, so that readParams and writeParams automatically run through the same parameters in the same order.

Definition at line 69 of file BaseObject.hpp.


The documentation for this class was generated from the following files: