CARLsim
4.1.0
CARLsim: a GPU-accelerated SNN simulator
|
Class SimpleWeightTuner. More...
#include <simple_weight_tuner.h>
Classes | |
class | Impl |
Private implementation of the Stopwatch Utility. More... | |
Public Member Functions | |
SimpleWeightTuner (CARLsim *sim, double errorMargin=1e-3, int maxIter=100, double stepSizeFraction=0.5) | |
Creates a new instance of class SimpleWeightTuner. More... | |
~SimpleWeightTuner () | |
Destructor. More... | |
bool | done (bool printMessage=false) |
Determines whether a termination criterion has been met. More... | |
void | iterate (int runDurationMs=1000, bool printStatus=true) |
Performs an iteration step of the tuning algorithm. More... | |
void | reset () |
Resets the algorithm to initial conditions. More... | |
void | setConnectionToTune (short int connId, double initWt=-1.0, bool adjustRange=true) |
Sets up the connection to tune. More... | |
void | setTargetFiringRate (int grpId, double targetRate) |
Sets up the target firing rate of a specific group. More... | |
The SimpleWeightTuner utility is a class that implements a simple search algorithm inspired by the bisection method.
The usage scenario is to tune the weights of a specific connection (collection of synapses) so that a specific neuron group fires at a predefined target firing rate—without having to recompile the network. A complete code example can be found in the Tutorial subfolder 12_advanced_topics/simple_weight_tuner.
Example usage:
tutorial/12_advanced_topics/simple_weight_tuner/main_simple_weight_tuner.cpp
Definition at line 88 of file simple_weight_tuner.h.
SimpleWeightTuner | ( | CARLsim * | sim, |
double | errorMargin = 1e-3 , |
||
int | maxIter = 100 , |
||
double | stepSizeFraction = 0.5 |
||
) |
This method creates a new instance of class SimpleWeightTuner. A SimpleWeightTuner can be used to tune weights on the fly; that is, without having to recompile and build a network. This is useful especially for tuning feedforward weights in large-scale networks that would otherwise take a long time to repeatedly build. For tuning in more complex situations please refer to ECJ (Parameter Tuning Interface).
[in] | sim | pointer to CARLsim object |
[in] | errorMargin | termination condition for error margin on target firing rate |
[in] | maxIter | termination condition for max number of iterations |
[in] | stepSizeFraction | step size for increasing/decreasing weights per iteration |
Definition at line 300 of file simple_weight_tuner.cpp.
~SimpleWeightTuner | ( | ) |
Cleans up all objects related to SimpleWeightTuner.
Definition at line 302 of file simple_weight_tuner.cpp.
bool done | ( | bool | printMessage = false | ) |
This method checks whether a termination criterion has been met, in which case true
is returned.
The algorithm will terminate if any of the following criteria have been met:
numberOfIter > maxIter
[in] | printMessage | flag whether to print message upon termination |
Definition at line 311 of file simple_weight_tuner.cpp.
void iterate | ( | int | runDurationMs = 1000 , |
bool | printStatus = true |
||
) |
This method runs the CARLsim network for a time period of runDurationMs
milliseconds, throughout which a SpikeMonitor is recording the firing rate of the group ID specified in setTargetFiringRate.
At the end of the iteration step the recorded firing rate is compared to the target firing rate, and the relative error is computed. If the error is smaller than the specified error margin, the algorithm terminates. If the maximum number of iteration steps is reached, the algorithm terminates. Otherwise the weights of the connection ID specified in setConnectionToTune() are updated, and the next iteration step is ready to be performed.
[in] | runDurationMs | time to run the CARLsim network (ms) |
[in] | printStatus | whether to print stats at the end of the iteration |
Definition at line 310 of file simple_weight_tuner.cpp.
void reset | ( | ) |
This method resets the algorithm to the initial conditions. It is implicitly called at the beginning and whenever setTargetFiringRate or setConnectionToTune has been called.
Definition at line 312 of file simple_weight_tuner.cpp.
void setConnectionToTune | ( | short int | connId, |
double | initWt = -1.0 , |
||
bool | adjustRange = true |
||
) |
This method sets up the connection ID to tune. The algorithm will repeatedely change the synaptic weights of this connection until the firing rate of a group (speficied via setTargetFiringRate) matches a certain target firing rate (specified in SimpleWeightTuner).
If the initial weight is set to a negative value, the algorithm will start with whatever weights have been specified when setting up the connection in CARLsim::connect. Otherwise a bias will be applied to all weights such that initWt
matches the field initWt
of the connection's RangeWeight struct.
If adjustRange is set to true, the [minWt,maxWt] ranges will be adjusted automatically should the weight go out of bounds.
Definition at line 304 of file simple_weight_tuner.cpp.
void setTargetFiringRate | ( | int | grpId, |
double | targetRate | ||
) |
This method sets up the target firing rate (Hz) of a specific group to achieve via changing the weights of the connection specified in setConnectionToTune.
A SpikeMonitor will be set up for the group if it does not already exist. SpikeMonitor::getPopMeanFiringRate will be used to determine the group's firing activity, and compare it to targetRate
in order to compute the error margin.
[in] | grpId | the group ID |
[in] | targetRate | target firing rate (Hz) of the group |
Definition at line 307 of file simple_weight_tuner.cpp.