A network model is defined by the user by providing the function
in a separate file, such as MyModel.cc
. In this function, the following tasks must be completed:
A network model is defined as follows:
- The name of the model must be definedA pygenn.GeNNModel must be created with a name and a default precision (see Floating point precision):
model = GeNNModel("float", "YourModelName")
By default the model will use a hardware-accelerated code-generation backend if it is available. However, this can be overriden using the
backend
keyword argument. For example, the single-threaded CPU backend could be manually selected with:
model = GeNNModel("float", "YourModelName",
backend="SingleThreadedCPU")
- Neuron populations (at least one) must be added (see Defining neuron populations). The user may add as many neuron populations as they wish. However, before this breaking point is reached, GeNN will make all necessary efforts in terms of block size optimisation to accommodate the defined models. All populations must have a unique name.
- Synapse populations (zero or more) can be added (see Defining synapse populations).
- Current sources (zero or more) can be added to neuron populations (see Defining current sources).
- Custom updates (zero or more) can be added (see Defining custom updates).
- Note
- If your model requires more memory than your GPU has available, there will be a warning but GeNN will not fail.
Defining neuron populations
Neuron populations are added using the function
model.add_neuron_population(pop_name, num_neurons, neuron, param_space, var_space)
where the arguments are:
-
NeuronModel
: Template argument specifying the type of neuron model. These should be derived off NeuronModels::Base and can either be one of the standard models or user-defined neuron
: The type of neuron model. This should either be a string containing the name of a built in model or user-defined neuron type returned by pygenn.genn_model.create_custom_neuron_class (see Neuron models).
-
const string &name
pop_name
: Unique name of the neuron population
-
unsigned int size
num_neurons
: number of neurons in the population
-
NeuronModel::ParamValues paramValues
: Parameters param_space
: Dictionary containing parameters of this neuron type
-
NeuronModel::VarValues varInitialisers
: Initial var_space
: Dictionary containing initial values or initialisation snippets for variables of this neuron type (see Variable initialisation)
The user may add as many neuron populations as the model necessitates. They must all have unique names. The possible values for the arguments, predefined models and their parameters and initial values are detailed Neuron models below.
Defining synapse populations
Synapse populations are added with the function
model.
addSynapsePopulation<WeightUpdateModel, PostsynapticModel>(name, mType, delay, preName, postName,
weightParamValues, weightVarValues, weightPreVarInitialisers, weightPostVarInitialisers,
postsynapticParamValues, postsynapticVarValues, connectivityInitialiser);
model.add_synapse_population(pop_name, matrix_type, delay_steps,
source, target, w_update_model, wu_param_space,
wu_var_space, wu_pre_var_space,
wu_post_var_space, postsyn_model,
ps_param_space, ps_var_space,
connectivity_initialiser
where the arguments are
-
WeightUpdateModel
: Template parameter specifying the type of weight update model. These should be derived off WeightUpdateModels::Base and can either be one of the standard models or user-defined w_update_model
: The type of weight update model. This should either be a string containing the name of a built in model or user-defined weight update model returned by pygenn.genn_model.create_custom_weight_update_class (see Weight update models).
-
PostsynapticModel
: Template parameter specifying the type of postsynaptic integration model. These should be derived off PostsynapticModels::Base and can either be one of the standard models or user-defined postsyn_model
: The type of postsynaptic model. This should either be a string containing the name of a built in model or user-defined postsynaptic model returned by pygenn.genn_model.create_custom_postsynaptic_class (see Postsynaptic integration methods).
-
const string &name
pop_name
: The name of the synapse population
-
SynapseMatrixType mType
: How matrix_type
: String specifying how the synaptic matrix is stored. See Synaptic matrix types for available options.
-
unsigned int delay
delay_steps
: Homogeneous (axonal) delay for synapse population (in terms of the simulation time step DT
).
-
const string preName
: Name source
: pygenn.NeuronGroup or name of the (existing!) presynaptic neuron population.
-
const string postName
: Name target
: pygenn.NeuronGroup or name of the (existing!) postsynaptic neuron population.
-
WeightUpdateModel::ParamValues weightParamValues
: The wu_param_space
: Dictionary containing the parameter values (common to all synapses of the population) for the weight update model.
- `
WeightUpdateModel::VarValues weightVarInitialisers
: The wu_var_space
: Dictionary containing the initial values or initialisation snippets for the weight update model's state variables (see Variable initialisation)
-
WeightUpdateModel::PreVarValues weightPreVarInitialisers
: The wu_pre_var_space
: Dictionary containing the initial values or initialisation snippets for the weight update model's presynaptic state variables (see Variable initialisation)
-
WeightUpdateModel::PostVarValues weightPostVarInitialisers
: The wu_post_var_space
: Dictionary containg the initial values or initialisation snippets for the weight update model's postsynaptic state variables (see Variable initialisation)
-
PostsynapticModel::ParamValues postsynapticParamValues
: The ps_param_space
: Dictionary containing the parameter values (common to all postsynaptic neurons) for the postsynaptic model.
-
PostsynapticModel::VarValues postsynapticVarInitialisers
: The ps_var_space
: Dictionary containing the initial values or initialisation snippets for variables for the postsynaptic model's state variables (see Variable initialisation)
-
InitSparseConnectivitySnippet::Init connectivityInitialiser
connectivity_initialiser
: Optional argument, specifying the initialisation snippet for synapse population's sparse connectivity (see Sparse connectivity initialisation).
- Note
- If the synapse matrix uses one of the "GLOBALG" types then the global value of the synapse parameters are taken from the initial value provided in
weightVarInitialisers
therefore these must be constant rather than sampled from a distribution etc.
Defining current sources
Current sources are added with the function
model.
addCurrentSource<CurrentSourceModel>(currentSourceName, targetNeuronGroupName,
paramValues, varInitialisers);
model.add_current_source(cs_name, current_source_model, pop,
param_space, var_space)
where the arguments are
-
CurrentSourceModel
: Template parameter specifying the type of current source model. These should be derived off CurrentSourceModels::Base and can either be one of the standard models or user-defined current_source_model
: The type of current source model. This should either be a string containing the name of a built in model or user-defined current source model returned by pygenn.genn_model.create_custom_current_source_class (see Defining your own current source model).
-
const string ¤tSourceName
cs_name
: The name of the current source
-
const string &targetNeuronGroupName
: Name of the target neuron group pop
: Population into which the current source should be injected (either name or NeuronGroup object)
-
CurrentSourceModel::ParamValues paramValues
: The param_space
: Dictionary containing the parameter values (common to all current sources in the population) for the current source model.
- `
CurrentSourceModel::VarValues varInitialisers
: The var_space
: Dictionary containing the initial values or initialisation snippets for the current source model's state variables (see Variable initialisation) - Note
- The number of current sources in a population always equals the number of neurons in the population it injects current into.
Defining custom updates
Custom updates are added with the function
paramValues, varInitialisers, varReferences, egpReferences)
model.add_custom_update(cu_name, group_name, custom_update_model,
param_space, var_space, var_ref_space, egp_ref_space)
where the arguments are
-
CustomUpdateModel
: Template parameter specifying the type of custom update model. These should be derived off CustomUpdateModels::Base and can either be one of the standard models or user-defined custom_update_model
: The type of custom update model. This should either be a string containing the name of a built in model or user-defined custom update model returned by pygenn.genn_model.create_custom_custom_update_class (see Defining your own custom update model).
-
const string &name
cu_name
: The name of the custom update
-
const string &updateGroupName
group_name
: The name of the group this custom update belongs to. Updates in each group can be launched as described in Simulating a network model.
-
CustomUpdateModel::ParamValues paramValues
: The param_space
: Dictionary containing the parameter values (common to all custom updates in the population) for the custom update model.
-
CustomUpdateModel::VarValues varInitialisers
: The var_space
: Dictionary containing the initial values or initialisation snippets for the custom update model's state variables (see Variable initialisation)
-
CustomUpdateModel::VarReferences varReferences
: The var_ref_space
: Dictionary containing the variable references for the custom update model (see Variable references)
-
CustomUpdateModel::EGPReferences egpReferences
: The egp_ref_space
: Dictionary containing the extra global parameter references for the custom update model (see Extra Global Parameter references)
Batching
When running models on a GPU, smaller models may not fully occupy the device. In some scenerios such as gradient-based training and parameter sweeping, this can be overcome by runing multiple copies of the same model at the same time (batching in Machine Learning speak). Batching can be enabled on a GeNN model with:
Model parameters and sparse connectivity are shared across all batches. Read-write state variables are duplicated for each batch and, by default, read-only state variables are shared across all batches (see section
Neuron models for more details).
Previous | Top | Next