NeuralEnsemble / PyNN

A Python package for simulator-independent specification of neuronal network models.
Other
276 stars 126 forks source link

STDP Mechanism: Fail to set tau_minus to a RandomDistribution #662

Closed hasref closed 3 years ago

hasref commented 4 years ago

I am using STDPMechanism with pyNN.nest in a simulation where I want to randomize tau_plus and tau_minus. Setting tau_plus to a RandomDistribution works just fine. However, setting tau_minus does not:

sim.STDPMechanism(
    timing_dependence=sim.SpikePairRule(A_plus = 0.1,  
    A_minus = 0.1,
    tau_minus = RandomDistribution('uniform', (20,40)),
    tau_plus = self.tau_plus),

results in

Traceback (most recent call last):

  File "/home/usr/src/examples/stdp_reservoir_example.py", line 53, in <module>
    lsm = LifStdp(num_exic,num_inhib, timestep=100, tau_minus = tau_minus, tau_plus = tau_plus)

  File "/home/usr/src/snn/Lsm.py", line 406, in __init__
    d_mean, d_var, timestep, tau_plus, tau_minus, max_activation)

  File "/home/usr/src/snn/Lsm.py", line 266, in __init__
    self._create_connections()

  File "/home/usr/src/snn/Lsm.py", line 425, in _create_connections
    super()._create_connections()

  File "/home/usr/src/snn/Lsm.py", line 317, in _create_connections
    receptor_type='excitatory')

  File "/home/usr/miniconda3/envs/src/lib/python3.7/site-packages/pyNN/nest/projections.py", line 47, in __init__
    self.nest_synapse_model = self.synapse_type._get_nest_synapse_model()

  File "/home/usr/miniconda3/envs/src/lib/python3.7/site-packages/pyNN/nest/standardmodels/synapses.py", line 72, in _get_nest_synapse_model
    synapse_defaults.pop("tau_minus")

KeyError: 'tau_minus'

Additionally, it does not seem possible to set tau_minus through the projection either:

>>> lsm_proj.set( tau_minus = RandomDistribution('uniform', (20,40) ) )

Traceback (most recent call last):

  File "<ipython-input-3-0b2e43973429>", line 1, in <module>
    lsm_proj.set( tau_minus = RandomDistribution('uniform', (20,40) ) )

  File "/home/usr/miniconda3/envs/src/lib/python3.7/site-packages/pyNN/common/projections.py", line 185, in set
    self._set_attributes(parameter_space)

  File "/home/usr/miniconda3/envs/src/lib/python3.7/site-packages/pyNN/nest/projections.py", line 267, in _set_attributes
    nest.SetStatus(connections, name, value[source_mask])

  File "/home/usr/miniconda3/envs/src/lib/python3.7/site-packages/nest/ll_api.py", line 246, in stack_checker_func
    return f(*args, **kwargs)

  File "/home/usr/miniconda3/envs/src/lib/python3.7/site-packages/nest/lib/hl_api_info.py", line 269, in SetStatus
    sr('Transpose { arrayload pop SetStatus } forall')

  File "/home/usr/miniconda3/envs/src/lib/python3.7/site-packages/nest/ll_api.py", line 132, in catching_sli_run
    raise exceptionCls(commandname, message)

NESTErrors.DictError: ('DictError in SetStatus_CD: Unused dictionary items:  tau_minus\nMaybe you tried to set common synapse properties through an individual synapse?', 'DictError', <SLILiteral: SetStatus_CD>, ': Unused dictionary items:  tau_minus\nMaybe you tried to set common synapse properties through an individual synapse?')

While setting tau_plus works fine:

>>>lsm_proj.set( tau_plus = RandomDistribution('uniform', (20,40) ) )

I am using pyNN 0.9.5 and nest 2.18.0.

apdavison commented 3 years ago

@has-ash first of all I'm sorry it has taken to long to deal with this; things have been very hectic this past year; the pace of PyNN development should pick up soon, though, with a couple of new people coming on board.

Unfortunately, NEST does not support fully heterogeneous values for tau_minus, because tau_minus is a parameter of the postsynaptic neuron, not of the synapse model (I assume this is for performance reasons). If partly-heterogeneous connections (all synapses onto a given post-synaptic neuron have the same tau_minus, but this can vary between neurons) would be useful, let me know and I'll implement it.

A complete fix for this would require someone to write a new NEST synapse model.

In the meantime, I've improved the error messages to give a better explanation of the situation.