Class SimpleWeightTuner.
More...
#include <simple_weight_tuner.h>
|
class | Impl |
| Private implementation of the Stopwatch Utility. 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:
SWT.setConnectionToTune(c0, 0.0);
SWT.setTargetFiringRate(gOut, 27.4);
while (!SWT.done()) {
SWT.iterate();
}
- See also
- Tutorial: 12.4.1 Simple Weight Tuner
-
Code example:
tutorial/12_advanced_topics/simple_weight_tuner/main_simple_weight_tuner.cpp
- Since
- v3.0
Definition at line 92 of file simple_weight_tuner.h.
◆ SimpleWeightTuner()
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).
- Parameters
-
[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 |
- Since
- v3.0
- See also
- ch10_ecj
Definition at line 302 of file simple_weight_tuner.cpp.
◆ ~SimpleWeightTuner()
◆ done()
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:
- The firing rate is close enough to the target: `currentFiring - targetFiring < errorMargin'
- The maximum number of iteration step has been reached:
numberOfIter > maxIter
- Parameters
-
[in] | printMessage | flag whether to print message upon termination |
- Since
- v3.0
Definition at line 313 of file simple_weight_tuner.cpp.
◆ iterate()
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.
- Parameters
-
[in] | runDurationMs | time to run the CARLsim network (ms) |
[in] | printStatus | whether to print stats at the end of the iteration |
- Since
- v3.0
- See also
- CARLsim::runNetwork
Definition at line 312 of file simple_weight_tuner.cpp.
◆ 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.
- Since
- v3.0
Definition at line 314 of file simple_weight_tuner.cpp.
◆ setConnectionToTune()
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.
- See also
- CARLsim::connect
-
RangeWeight
-
CARLsim::biasWeights
- Since
- v3.0
Definition at line 306 of file simple_weight_tuner.cpp.
◆ setTargetFiringRate()
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.
- Parameters
-
[in] | grpId | the group ID |
[in] | targetRate | target firing rate (Hz) of the group |
- Attention
- If a SpikeMonitor already exists for this group, SimpleWeightTuner will use the same one and turn PersistentMode off.
- Since
- v3.0
- See also
- SpikeMonitor
Definition at line 309 of file simple_weight_tuner.cpp.
The documentation for this class was generated from the following files: