GeNN
3.3.0
GPU enhanced Neuronal Networks (GeNN)
|
Neuron, weight update and postsynaptic models all have state variables which GeNN can automatically initialise.
Previously we have shown variables being initialised to constant values such as:
state variables can also be left uninitialised leaving it up to the user code to initialise them:
or initialised using one of a number of predefined variable initialisation snippets:
For example, to initialise a parameter using values drawn from the normal distribution:
Similarly to neuron, weight update and postsynaptic models, new variable initialisation snippets can be created by simply defining a class in the model description. For example, when initialising excitatory (positive) synaptic weights with a normal distribution they should be clipped at 0 so the long tail of the normal distribution doesn't result in negative weights. This could be implemented using the following variable initialisation snippet which redraws until samples are within the desired bounds:
Within the snippet of code specified using the SET_CODE()
macro, when initialisising neuron and postaynaptic model state variables , the $(id) variable can be used to access the id of the neuron being initialised. Similarly, when initialising weight update model state variables, the $(id_pre) and $(id_post) variables can used to access the ids of the pre and postsynaptic neurons connected by the synapse being initialised.
Once you have defined how your variables are going to be initialised you need to configure where they will be initialised and allocated. By default memory is allocated for variables on both the GPU and the host; and variables are initialised on the host as described in section Variable initialisation and then uploaded to the GPU. However, variable initialisation can also be offloaded to the GPU, potentially reducing the time spent both calculating the initial values and uploading them. To enable this functionality the following alternative modes of operation are available:
These modes can be set as a global default using GENN_PREFERENCES::defaultVarMode
or on a per-variable basis using one of the following functions: