Modifying connectivity densities at runtime #527
Replies: 1 comment
-
That is an interesting question! In most cases, you could indeed apply a very similar approach and create a modified version of, for example the FixedProbability connectivity initialisation snippet, with the parameters replaced by an extra global parameter. The only slightly tricky part is that you will also need an actual parameter specifying the densest configuration to allow the However, the Potjans microcircuit (and multi-area model) use a "fixed total number" connection pattern which, as described in https://www.frontiersin.org/article/10.3389/fnins.2018.00941/full, requires some CPU computation before it can be generated on the GPU (this bit of code). This is already done through an extra global parameter array called sg.connectivity_extra_global_params["preCalcRowLength"].view =\
sg._assign_ext_ptr_array("preCalcRowLength",
sg.src.size,
"uint16_t") Then, when you want to update the connectivity density you need to build a new from scipy.stats import binom
def build_row_lengths(sg, num_connections):
remaining_connections = num_connections
matrix_size = sg.src.size * sg.trg.size
row_lengths = sg.connectivity_extra_global_params["preCalcRowLength"].view
for i in range(sg.src.size- 1):
probability = float(sg.trg.size) / float(matrix_size)
# Sample row length;
row_lengths[i] = binom.rvs(remaining_connections, probability)
# Update counters
remaining_connections -= row_lengths[i]
matrix_size -= sg.trg.size
# Insert remaining connections into last row
row_lengths[num_pre - 1] = remaining_connections Finally, you would upload the updated row lengths to the GPU and reininitialize the model: sg._push_extra_global_param_to_device("preCalcRowLength", sg.connectivity_extra_global_params)
model.reinitialize() |
Beta Was this translation helpful? Give feedback.
-
@pabloabur
Would the approach described below be different if instead of adjusting the LIF cell parameters, instead if network connection density parameters where changed, but population cell count was constant.
Make tunable variables for connection densities and cell counts:
Then, once you add your population you can initialise your extra global parameter like:
And then change it freely at runtime with
This approach works for almost everything including variable initialisation (although there you need to call model.reinitialize() to resample distributions). Hope that makes sense, most of this is described in the manual at https://genn-team.github.io/genn/documentation/4/html/de/ded/sectNeuronModels.html#neuron_extra_global_param and https://genn-team.github.io/genn/documentation/4/html/d0/da6/UserGuide.html#extraGlobalParamSim (click the Python button at the top)
Beta Was this translation helpful? Give feedback.
All reactions