Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot simulate PointNet network with custom set_syn_weight function #381

Open
MargauxCalice opened this issue Aug 27, 2024 · 0 comments
Open

Comments

@MargauxCalice
Copy link

Hello!

I built a pointnet network for which I used add_properties to define the delays with a given rule. By doing that, i deleted the "nsyn" section in the edge h5 file (which is compensated by adding multiple time a connection in the edge h5 file according to its number of synapses). However, during the simulation of the config file I get this error:

Traceback (most recent call last):
  File "/gpfs/users/calicem/.conda/envs/ENV_NEST33/BMTK_Simulations/grid_searching_l4l4.py", line 31, in <module>
    sim = pointnet.PointSimulator.from_config(configure, graph)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/gpfs/users/calicem/.conda/envs/ENV_NEST33/lib/python3.11/site-packages/bmtk/simulator/pointnet/pointsimulator.py", line 243, in from_config
    graph.build_recurrent_edges()
  File "/gpfs/users/calicem/.conda/envs/ENV_NEST33/lib/python3.11/site-packages/bmtk/simulator/pointnet/pointnetwork.py", line 167, in build_recurrent_edges
    for edge in edge_pop.get_edges():
  File "/gpfs/users/calicem/.conda/envs/ENV_NEST33/lib/python3.11/site-packages/bmtk/simulator/core/sonata_reader/network_reader.py", line 191, in get_edges
    for edge in edge_adaptor.get_batches(edge_group):
  File "/gpfs/users/calicem/.conda/envs/ENV_NEST33/lib/python3.11/site-packages/bmtk/simulator/pointnet/sonata_adaptors.py", line 335, in get_batches
    type_params[edge_id]['weight'] = weight_fnc(edges, source_nodes, target_nodes)
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/gpfs/users/calicem/.conda/envs/ENV_NEST33/lib/python3.11/site-packages/bmtk/simulator/pointnet/default_setters/synaptic_weights.py", line 7, in default_weight_fnc
    return np.array(edge_props['syn_weight']*edge_props.nsyns)
                                             ^^^^^^^^^^^^^^^^
  File "/gpfs/users/calicem/.conda/envs/ENV_NEST33/lib/python3.11/site-packages/pandas/core/generic.py", line 6296, in __getattr__
    return object.__getattribute__(self, name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'DataFrame' object has no attribute 'nsyns'
srun: error: node105: task 0: Exited with exit code 1

I tried to overwrite the default set_syn_weight function by building my own set_syn_weight function (which I will also need to use in the future since I want to do a grid searching in order to find an optimal synaptic weight according to a targeted output frequency):

list_grid=[1,2,3,4]
grid_search = {
    'exc':list_grid,
    'in':[0]*len(list_grid)
}

@synaptic_weight
def set_syn_weight(edge_props, source_nodes, target_nodes):

    target_type = target_nodes['cell_line'].unique()[0]
    new_syn_weight = grid_search[target_type][current_itr]
    
    weights_table[target_type].append(new_syn_weight)
    
    return np.array(new_syn_weight*edge_props.nsyns)

But I get this error:

Traceback (most recent call last):
  File "/gpfs/users/calicem/.conda/envs/ENV_NEST33/BMTK_Simulations/grid_searching_l4l4.py", line 95, in <module>
    sim = pointnet.PointSimulator.from_config(configure, graph)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/gpfs/users/calicem/.conda/envs/ENV_NEST33/lib/python3.11/site-packages/bmtk/simulator/pointnet/pointsimulator.py", line 243, in from_config
    graph.build_recurrent_edges()
  File "/gpfs/users/calicem/.conda/envs/ENV_NEST33/lib/python3.11/site-packages/bmtk/simulator/pointnet/pointnetwork.py", line 173, in build_recurrent_edges
    self._nest_connect(nest_srcs, nest_trgs, conn_spec='one_to_one', syn_spec=edge.nest_params)
  File "/gpfs/users/calicem/.conda/envs/ENV_NEST33/lib/python3.11/site-packages/bmtk/simulator/pointnet/pointnetwork.py", line 232, in _nest_connect
    nest.Connect(nest_srcs, nest_trgs, conn_spec=conn_spec, syn_spec=syn_spec)
  File "/gpfs/users/calicem/.conda/envs/ENV_NEST33/lib/python3.11/site-packages/nest/ll_api.py", line 229, in stack_checker_func
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "/gpfs/users/calicem/.conda/envs/ENV_NEST33/lib/python3.11/site-packages/nest/lib/hl_api_connections.py", line 257, in Connect
    connect_arrays(pre, post, weights, delays, synapse_model, syn_param_keys, syn_param_values)
  File "pynestkernel.pyx", line 300, in pynestkernel.NESTEngine.connect_arrays
TypeError: weights must be a 1-dimensional NumPy array
srun: error: node200: task 0: Exited with exit code 1

I changed the function with:

return np.array(new_syn_weight*pd.Series([1]))

But then again I get this error:

Traceback (most recent call last):
  File "/gpfs/users/calicem/.conda/envs/ENV_NEST33/BMTK_Simulations/grid_searching_l4l4.py", line 95, in <module>
    sim = pointnet.PointSimulator.from_config(configure, graph)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/gpfs/users/calicem/.conda/envs/ENV_NEST33/lib/python3.11/site-packages/bmtk/simulator/pointnet/pointsimulator.py", line 243, in from_config
    graph.build_recurrent_edges()
  File "/gpfs/users/calicem/.conda/envs/ENV_NEST33/lib/python3.11/site-packages/bmtk/simulator/pointnet/pointnetwork.py", line 173, in build_recurrent_edges
    self._nest_connect(nest_srcs, nest_trgs, conn_spec='one_to_one', syn_spec=edge.nest_params)
  File "/gpfs/users/calicem/.conda/envs/ENV_NEST33/lib/python3.11/site-packages/bmtk/simulator/pointnet/pointnetwork.py", line 232, in _nest_connect
    nest.Connect(nest_srcs, nest_trgs, conn_spec=conn_spec, syn_spec=syn_spec)
  File "/gpfs/users/calicem/.conda/envs/ENV_NEST33/lib/python3.11/site-packages/nest/ll_api.py", line 229, in stack_checker_func
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "/gpfs/users/calicem/.conda/envs/ENV_NEST33/lib/python3.11/site-packages/nest/lib/hl_api_connections.py", line 214, in Connect
    processed_syn_spec = _process_syn_spec(
                         ^^^^^^^^^^^^^^^^^^
  File "/gpfs/users/calicem/.conda/envs/ENV_NEST33/lib/python3.11/site-packages/nest/lib/hl_api_connection_helpers.py", line 89, in _process_syn_spec
    raise kernel.NESTError(
nest.lib.hl_api_exceptions.NESTErrors.NESTError: 'weight' has to be an array of dimension 299430.
srun: error: node200: task 0: Exited with exit code 1

How can I build my own set_syn_weight function and avoid this issue ?

I am using NEST 3.3 and BMTK 1.0.8.

Thanks in advance for your help,
Margaux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant