Description of problem
I am trying to simulate a mixed analog-digital neuromorphic environment with brian2cuda (everything works flawlessly with just brian2), so I need to have noisy initialization of parameters. Problem is, with brian2cuda certain parameters seem to have the possibility to be initialized only with scalars (I would avoid to create a for loop for every neurongroups, it would kill the efficiency of standalone code generation)
Minimal code to reproduce problem
I am using custom neural and synaptic model so I won’t attach the full model. Please note that the initialization of weight does not give any issues, which appear when I try to initialize the C_syn_exc2 parameter.
from brian2 import *
import brian2cuda
set_device('cuda_standalone', directory='my_folder', compile=True)
n_class = 50
inh_len = n_class*9*90
s_ei_C = np.random.normal(loc=1, scale=0.2, size=inh_len)* 1.5
s_ei = chip.add_connection (L1,L_inh,synapse_type='AMPA')
s_ei.connect (True)
s_ei.weight = np.random.normal(loc=1, scale=0.2, size=inh_len)*30
s_ei.C_syn_exc2 = 's_ei_C*pF'
=========================
What you have aready tried
- initializing directly:
s_ei.C_syn_exc2= np.random.normal(loc=1, scale=0.2, size=inh_len)* 1.5
- initialize a dictionary and passing the key:
s_ei_C = np.random.normal(loc=1, scale=0.2, size=inh_len)* 1.5
params = {'s_ei_C':s_ei_C
}
s_ei.C_syn_exc2 = params['s_ei_C']
- initializing without the string format:
s_ei.C_syn_exc2 = s_ei_C*pF
====================
Actual output (if relevant)
KeyError: ‘Variable s_ei_C was found in the namespace, but is not a scalar value’
==================
Full traceback of error (if relevant)
Cell In[1], line 158
s_ei.C_syn_exc2 = 's_ei_C*pF'
File ~/anaconda3/envs/CUDA/lib/python3.10/site-packages/brian2/groups/group.py:424 in __setattr__
var.get_addressable_value_with_unit(name, self).set_item(slice(None),
File ~/anaconda3/envs/CUDA/lib/python3.10/site-packages/brian2/core/variables.py:876 in set_item
self.set_with_expression_conditional(item, value,
File ~/anaconda3/envs/CUDA/lib/python3.10/site-packages/brian2/core/base.py:278 in device_override_decorated_function
return func(*args, **kwds)
File ~/anaconda3/envs/CUDA/lib/python3.10/site-packages/brian2/core/variables.py:1033 in set_with_expression_conditional
codeobj = create_runner_codeobj(self.group,
File ~/anaconda3/envs/CUDA/lib/python3.10/site-packages/brian2/codegen/codeobject.py:355 in create_runner_codeobj
variables = group.resolve_all(identifiers | set(needed_variables) | set(template_variables),
File ~/anaconda3/envs/CUDA/lib/python3.10/site-packages/brian2/groups/group.py:737 in resolve_all
resolved[identifier] = self._resolve(identifier,
File ~/anaconda3/envs/CUDA/lib/python3.10/site-packages/brian2/groups/group.py:697 in _resolve
return self._resolve_external(identifier, run_namespace=run_namespace)
File ~/anaconda3/envs/CUDA/lib/python3.10/site-packages/brian2/groups/group.py:903 in _resolve_external
raise KeyError('Variable %s was found in the namespace, but is'
KeyError: 'Variable s_ei_C was found in the namespace, but is not a scalar value'
========================
Thenk you very much in advance for the help