GeNN  3.3.0
GPU enhanced Neuronal Networks (GeNN)
Sparse connectivity initialisation

Sparse synaptic connectivity implemented using SynapseMatrixConnectivity::RAGGED and SynapseMatrixConnectivity::BITMASK can be automatically initialised.

This can be done using one of a number of predefined sparse connectivity initialisation snippets:

For example, to initialise synaptic connectivity with a 10% connection probability (allowing connections between neurons with the same id):

InitSparseConnectivitySnippet::FixedProbability::ParamValues fixedProb(0.1);
...
initConnectivity<InitSparseConnectivitySnippet::FixedProbability>(fixedProb));

Defining a new sparse connectivity snippet

Similarly to variable initialisation snippets, sparse connectivity initialisation snippets can be created by simply defining a class in the model description.

For example, the following sparse connectivity initialisation snippet could be used to initialise a 'ring' of connectivity where each neuron is connected to a number of subsequent neurons specified using the numNeighbours parameter:

{
public:
DECLARE_SNIPPET(Ring, 1);
SET_ROW_BUILD_STATE_VARS({{"offset", {"unsigned int", 1}}}});
"const unsigned int target = ($(id_pre) + offset) % $(num_post);\n"
"$(addSynapse, target);\n"
"offset++;\n"
"if(offset > (unsigned int)$(numNeighbours)) {\n"
" $(endRow);\n"
"}\n");
SET_PARAM_NAMES({"numNeighbours"});
};

Each row of sparse connectivity is initialised independantly by running the snippet of code specified using the SET_ROW_BUILD_CODE() macro within a loop. The $(num_post) variable can be used to access the number of neurons in the postsynaptic population and the $(id_pre) variable can be used to access the index of the presynaptic neuron associated with the row being generated. The SET_ROW_BUILD_STATE_VARS() macro can be used to initialise state variables outside of the loop - in this case offset which is used to count the number of synapses created in each row. Synapses are added to the row using the $(addSynapse, target) function and iteration is stopped using the $(endRow) function.

Sparse connectivity initialisation modes

Once you have defined how sparse connectivity is going to be initialised, you need to configure where it will be initialised and allocated. This is controlled using the same VarMode options described in section Variable initialisation modes and can either be set using the global default specifiued with GENN_PREFERENCES::defaultSparseConnectivityMode or on a per-synapse group basis using SynapseGroup::setSparseConnectivityVarMode.


Previous | Top | Next