PetaVision  Alpha
 All Data Structures Namespaces Functions Variables
PV::FirmThresholdCostFnLCAProbe Class Reference

#include <FirmThresholdCostFnLCAProbe.hpp>

Inheritance diagram for PV::FirmThresholdCostFnLCAProbe:
PV::FirmThresholdCostFnProbe PV::AbstractNormProbe PV::LayerProbe PV::BaseProbe PV::BaseObject

AbstractNormProbe Parameters

List of parameters needed from the AbstractNormProbe class

virtual void ioParam_maskLayerName (enum ParamsIOFlag ioFlag)
 maskLayerName: Specifies a masking layer to use when calculating the norm. When blank (the default), masking is not used. More...
 

BaseProbe Parameters

List of parameters for the BaseProbe class

virtual void ioParam_message (enum ParamsIOFlag ioFlag)
 message: A string parameter that is typically included in the lines output by the outputState method
 
virtual void ioParam_textOutputFlag (enum ParamsIOFlag ioFlag)
 textOutputFlag: A boolean parameter that sets whether to generate an output file. Defaults to true.
 
virtual void ioParam_probeOutputFile (enum ParamsIOFlag ioFlag)
 probeOutputFile: If textOutputFlag is true, probeOutputFile specifies the name of the file that the outputState method writes to. If blank, the output is sent to the output stream.
 
virtual void ioParam_triggerFlag (enum ParamsIOFlag ioFlag)
 triggerFlag: If false, the needUpdate method always returns true, so that outputState is called every timestep. If true, the needUpdate method uses triggerLayerName and triggerOffset to determine if the probe should be triggered.
 
virtual void ioParam_triggerLayerName (enum ParamsIOFlag ioFlag)
 triggerLayerName: If triggerFlag is true, triggerLayerName specifies the layer to check for triggering.
 
virtual void ioParam_triggerOffset (enum ParamsIOFlag ioFlag)
 triggerOffset: If triggerFlag is true, triggerOffset specifies the time interval before the triggerLayer's nextUpdate time that needUpdate() returns true.
 
virtual void ioParam_energyProbe (enum ParamsIOFlag ioFlag)
 energyProbe: If nonblank, specifies the name of a ColumnEnergyProbe that this probe contributes an energy term to.
 

FirmThresholdCostFnProbe Parameters

List of parameters for the FirmThresholdCostFnProbe class

virtual void ioParam_VThresh (enum ParamsIOFlag ioFlag)
 VThresh: The threshold where the transfer function returns 0 if |V|<VThresh. If the target layer is an ANNLayer or one of its subclasses, the default is the target layer's VThresh; otherwise, the default is zero.
 
virtual void ioParam_VWidth (enum ParamsIOFlag ioFlag)
 VWidth: The width of the interval over which the transfer function changes from hard to soft threshold. If the target layer is an ANNLayer or one of its subclasses, the default is the target layer's VWidth; otherwise, the default is zero.
 

LayerProbe Parameters

List of parameters for the LayerProbe class

virtual void ioParam_targetName (enum ParamsIOFlag ioFlag)
 targetName: the name of the layer to attach the probe to. In LayerProbes, targetLayer can be used in the params file instead of targetName. LayerProbe looks for targetLayer first and then targetName.
 

Public Member Functions

 FirmThresholdCostFnLCAProbe (const char *probeName, HyPerCol *hc)
 
virtual int allocateDataStructures ()
 
virtual int communicateInitInfo ()
 
double getCoefficient ()
 
char const * getEnergyProbe ()
 
char const * getKeyword () const
 
HyPerLayergetMaskLayer ()
 
char const * getMaskLayerName ()
 
char const * getName () const
 
int getNumValues ()
 
HyPerColgetParent () const
 
HyPerLayergetTargetLayer ()
 
const char * getTargetName ()
 
double getValue (double timevalue, int index)
 
int getValues (double timevalue, double *valuesVector)
 
int getValues (double timevalue, std::vector< double > *valuesVector)
 
int ioParams (enum ParamsIOFlag ioFlag)
 
virtual bool needUpdate (double time, double dt)
 
virtual int outputStateWrapper (double timef, double dt)
 
virtual int writeTimer (std::ostream &stream)
 

Protected Member Functions

virtual int calcValues (double timeValue)
 
double getLastUpdateTime ()
 
const char * getMessage ()
 
char const * getNormDescription ()
 
OutStreamgetOutputStream ()
 
bool getTextOutputFlag () const
 
virtual double getValueInternal (double timevalue, int index)
 
int getValues (double timevalue)
 
double * getValuesBuffer ()
 
int initAbstractNormProbe (const char *probeName, HyPerCol *hc)
 
int initFirmThresholdCostFnLCAProbe (const char *probeName, HyPerCol *hc)
 
int initFirmThresholdCostFnProbe (const char *probeName, HyPerCol *hc)
 
int initialize (const char *probeName, HyPerCol *hc)
 
virtual int initMessage (const char *msg)
 
virtual int initNumValues ()
 
virtual int initOutputStream (const char *filename)
 
virtual void ioParam_coefficient (enum ParamsIOFlag ioFlag)
 
virtual int ioParamsFillGroup (enum ParamsIOFlag ioFlag)
 
bool isWritingToFile () const
 
bool maskHasSingleFeature ()
 
virtual bool needRecalc (double timevalue)
 
std::ostream & output ()
 
virtual int outputState (double timevalue)
 
virtual double referenceUpdateTime () const
 
int setName (char const *name)
 
virtual int setNormDescription ()
 
int setNormDescriptionToString (char const *s)
 
int setNumValues (int n)
 
int setParent (HyPerCol *hc)
 

Protected Attributes

double coefficient
 
char * energyProbe
 
char * name
 
OutStreamoutputStream
 
HyPerColparent
 
HyPerLayertargetLayer
 
char * targetName
 
bool triggerFlag
 
HyPerLayertriggerLayer
 
char * triggerLayerName
 
double triggerOffset
 
pvpotentialdata_t VThresh
 
pvpotentialdata_t VWidth
 

Private Member Functions

int initialize_base ()
 

Detailed Description

A special case of FirmThresholdCostFnProbe, to be used when the target layer is an LCA layer with a hard-threshold transfer function. The corresponding cost function is the norm measured by FirmThresholdCostFnProbe, with coefficient Vth, where Vth is the target LCA layer's VThresh.

Definition at line 20 of file FirmThresholdCostFnLCAProbe.hpp.

Member Function Documentation

int PV::BaseProbe::allocateDataStructures ( )
virtualinherited

Called during HyPerCol::run, during the allocateDataStructures stage. BaseProbe::allocateDataStructures sets up the output stream. Derived classes that override this method should make sure to call this method in their own allocateDataStructures methods.

Reimplemented in PV::KernelProbe.

Definition at line 255 of file BaseProbe.cpp.

int PV::AbstractNormProbe::calcValues ( double  timeValue)
protectedvirtualinherited

Computes the norms. Each MPI process calls getValueInternal to compute its own contribution to the norms, and then calcValues calls MPI_Allreduce.

Implements PV::BaseProbe.

Reimplemented in PV::L2NormProbe.

Definition at line 112 of file AbstractNormProbe.cpp.

int PV::FirmThresholdCostFnLCAProbe::communicateInitInfo ( )
virtual

Calls LayerProbe::communicateInitInfo to set up the targetLayer and attach the probe; and then checks the masking layer if masking is used.

Reimplemented from PV::FirmThresholdCostFnProbe.

Definition at line 22 of file FirmThresholdCostFnLCAProbe.cpp.

double PV::BaseProbe::getCoefficient ( )
inlineinherited

Returns the coefficient if the energy probe is set.

Definition at line 101 of file BaseProbe.hpp.

char const* PV::BaseProbe::getEnergyProbe ( )
inlineinherited

Returns the name of the energy probe the probe is attached to (null if not attached to an energy probe)

Definition at line 96 of file BaseProbe.hpp.

double PV::BaseProbe::getLastUpdateTime ( )
inlineprotectedinherited

Returns the time that calcValues was last called. BaseProbe updates the last update time in getValues() and getValue(), based on the result of needRecalc.

Definition at line 289 of file BaseProbe.hpp.

HyPerLayer* PV::AbstractNormProbe::getMaskLayer ( )
inlineinherited

Returns a pointer to the masking layer. Returns NULL if masking is not used.

Definition at line 33 of file AbstractNormProbe.hpp.

char const* PV::AbstractNormProbe::getMaskLayerName ( )
inlineinherited

Returns the name of the masking layer, as given by the params. maskLayerName is not set in params, it returns NULL.

Definition at line 39 of file AbstractNormProbe.hpp.

const char* PV::BaseProbe::getMessage ( )
inlineprotectedinherited

Returns a pointer to the message parameter.

Definition at line 244 of file BaseProbe.hpp.

int PV::BaseProbe::getNumValues ( )
inlineinherited

Returns the number of value indices the probe can compute (typically the value of the parent HyPerCol's nBatch parameter). BaseProbe::getNumValues() returns the parent HyPerCol's getNBatch(), which can be overridden. Probes derived from BaseProbe can set numValues to zero or a negative number to indicate that getValues() and getNumValues() are not fully implemented for that probe.

Definition at line 71 of file BaseProbe.hpp.

OutStream* PV::BaseProbe::getOutputStream ( )
inlineprotectedinherited

Returns a pointer to the OutStream used by outputState.

Definition at line 255 of file BaseProbe.hpp.

const char* PV::BaseProbe::getTargetName ( )
inlineinherited

Returns the name of the targetName parameter for this probe. LayerProbe uses targetName to specify the layer to attach to; BaseConnectionProbe uses it to specify the connection to attach to.

Definition at line 91 of file BaseProbe.hpp.

bool PV::BaseProbe::getTextOutputFlag ( ) const
inlineprotectedinherited

Returns the value of the textOutputFlag parameter

Definition at line 294 of file BaseProbe.hpp.

double PV::BaseProbe::getValue ( double  timevalue,
int  index 
)
inherited

getValue() is meant for situations where the caller needs one value that would be returned by getValues(), not the whole buffer. getValue() returns a signaling NaN if index is out of bounds. If index is valid, getValue() calls calcValues() if needRecalc() returns true, and then returns probeValues[index]. Derived classes should not override or hide this method. Instead, they should override calcValues.

Definition at line 343 of file BaseProbe.cpp.

double PV::FirmThresholdCostFnProbe::getValueInternal ( double  timevalue,
int  index 
)
protectedvirtualinherited

getValueInternal(double, index) is a pure virtual function called by calcValues(). The index refers to the layer's batch element index.

Typically, getValueInternal should compute the contribution to the norm from its own MPI process. Then calcValues calls MPI_Allreduce.

Implements PV::AbstractNormProbe.

Definition at line 75 of file FirmThresholdCostFnProbe.cpp.

int PV::BaseProbe::getValues ( double  timevalue,
double *  valuesVector 
)
inherited

getValues(double timevalue, double * values) sets the buffer 'values' with the probe's calculated values. It assumes that the values buffer is large enough to hold getNumValues() double-precision values. If 'values' is NULL, the values are still updated internally if needed, but those values are not returned. Internally, getValues() calls calcValues() if needRecalc() is true. It then copies the probeValues buffer to the input argument buffer 'values'. Derived classes should not override or hide this method. Instead, they should override calcValues.

Definition at line 330 of file BaseProbe.cpp.

int PV::BaseProbe::getValues ( double  timevalue,
std::vector< double > *  valuesVector 
)
inherited

getValues(double timevalue, vector<double> * valuesVector) is a wrapper around getValues(double, double *) that uses C++ vectors. It resizes valuesVector to size getNumValues() and then fills the vector with the values returned by getValues.

Definition at line 338 of file BaseProbe.cpp.

int PV::BaseProbe::getValues ( double  timevalue)
protectedinherited

If needRecalc() returns true, getValues(double) updates the probeValues buffer (by calling calcValues) and sets lastUpdateTime to the timevalue input argument.

Definition at line 319 of file BaseProbe.cpp.

double* PV::BaseProbe::getValuesBuffer ( )
inlineprotectedinherited

Returns a pointer to the buffer containing the probeValues.

Definition at line 282 of file BaseProbe.hpp.

int PV::LayerProbe::initialize ( const char *  probeName,
HyPerCol hc 
)
protectedinherited

Definition at line 41 of file LayerProbe.cpp.

int PV::BaseProbe::initMessage ( const char *  msg)
protectedvirtualinherited

The method called by BaseProbe::initialize() to set the message used by the probe's outputState method.

Definition at line 264 of file BaseProbe.cpp.

int PV::BaseProbe::initNumValues ( )
protectedvirtualinherited

initNumValues is called by initialize. BaseProbe::initNumValues sets numValues to the parent HyPerCol's getNBatch(). Derived classes can override initNumValues to initialize numValues to a different value.

Reimplemented in PV::PointProbe, PV::KernelProbe, PV::StatsProbe, and PV::PointLIFProbe.

Definition at line 197 of file BaseProbe.cpp.

virtual void PV::FirmThresholdCostFnLCAProbe::ioParam_coefficient ( enum ParamsIOFlag  ioFlag)
inlineprotectedvirtual

FirmThresholdCostFnLCAProbe does not read coefficient from params, but computes it from VThresh of the target layer.

Reimplemented from PV::BaseProbe.

Definition at line 34 of file FirmThresholdCostFnLCAProbe.hpp.

void PV::AbstractNormProbe::ioParam_maskLayerName ( enum ParamsIOFlag  ioFlag)
protectedvirtualinherited

maskLayerName: Specifies a masking layer to use when calculating the norm. When blank (the default), masking is not used.

The motivation for maskLayerName is to use a layer of ones and zeros to mask out do-not-care regions when computing the norm. Note that for reasons of computation speed, it is up to derived classes to take masking into account when implementing getValueInternal(). The maskLayerName must refer to a layer in the HyPerCol with the same nxScale and nyScale as the probe's targetLayer, and have either the same number of features or a single feature.

Definition at line 53 of file AbstractNormProbe.cpp.

bool PV::BaseProbe::isWritingToFile ( ) const
inlineprotectedinherited

Returns true if a probeOutputFile is being used. Otherwise, returns false (indicating output is going to getOutputStream().

Definition at line 300 of file BaseProbe.hpp.

bool PV::AbstractNormProbe::maskHasSingleFeature ( )
inlineprotectedinherited

Returns true if masking is used and the layer has multiple features but the masking layer has a single feature. In this case it is expected that the single masking feature will be applied to all layer features. Not reliable until communicateInitInfo() has been called.

Definition at line 111 of file AbstractNormProbe.hpp.

bool PV::LayerProbe::needRecalc ( double  timevalue)
protectedvirtualinherited

Implements the needRecalc method. Returns true if the target layer's getLastUpdateTime method is greater than the probe's lastUpdateTime member variable.

Implements PV::BaseProbe.

Reimplemented in PV::StatsProbe.

Definition at line 80 of file LayerProbe.cpp.

bool PV::BaseProbe::needUpdate ( double  time,
double  dt 
)
virtualinherited

If there is a triggering layer, needUpdate returns true when the triggering layer's nextUpdateTime, modified by the probe's triggerOffset parameter, occurs; otherwise false. If there is not a triggering layer, needUpdate always returns true. This behavior can be overridden if a probe uses some criterion other than triggering to choose when output its state.

Definition at line 291 of file BaseProbe.cpp.

std::ostream& PV::BaseProbe::output ( )
inlineprotectedinherited

Returns a reference to the ostream that outputState writes to.

Definition at line 260 of file BaseProbe.hpp.

int PV::AbstractNormProbe::outputState ( double  timevalue)
protectedvirtualinherited

Implements the outputState method required by classes derived from BaseProbe. Prints to the outputFile the probe message, timestamp, number of neurons, and norm value for each batch element.

Implements PV::BaseProbe.

Definition at line 121 of file AbstractNormProbe.cpp.

int PV::BaseProbe::outputStateWrapper ( double  timef,
double  dt 
)
virtualinherited

The public interface for calling the outputState method. BaseConnection::outputStateWrapper calls outputState() if needUpdate() returns true. This behavior is intended to be general, but the method can be overridden if needed.

Definition at line 357 of file BaseProbe.cpp.

double PV::LayerProbe::referenceUpdateTime ( ) const
protectedvirtualinherited

Implements the referenceUpdateTime method. Returns the last update time of the target layer.

Implements PV::BaseProbe.

Definition at line 84 of file LayerProbe.cpp.

int PV::FirmThresholdCostFnProbe::setNormDescription ( )
protectedvirtualinherited

Overrides AbstractNormProbe::setNormDescription() to set normDescription to "Cost function". Return values and errno are set by a call to setNormDescriptionToString.

Reimplemented from PV::AbstractNormProbe.

Definition at line 52 of file FirmThresholdCostFnProbe.cpp.

int PV::AbstractNormProbe::setNormDescriptionToString ( char const *  s)
protectedinherited

A generic method for setNormDescription() implementations to call. It frees normDescription if it has already been set, and then copies the string in the input argument to the normDescription member variable. It returns PV_SUCCESS or PV_FAILURE; on failure it sets errno.

Definition at line 107 of file AbstractNormProbe.cpp.

int PV::BaseProbe::setNumValues ( int  n)
protectedinherited

Sets the numValues member variable (returned by getNumValues()) and reallocates the probeValues member variable to hold numValues double-precision values. If the reallocation fails, the probeValues buffer is left unchanged, errno is set (by a realloc() call), and PV_FAILURE is returned. Otherwise, PV_SUCCESS is returned.

Definition at line 201 of file BaseProbe.cpp.


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