# About Network class

**URL:** <https://brian.discourse.group/t/about-network-class/864>\
**Category:** Support\
**Tags:** network, names\
**Created:** [14 January 2023 17:58 UTC](https://brian.discourse.group/t/about-network-class/864 "2023-01-14T17:58:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![caccola816](https://avatars.discourse-cdn.com/v4/letter/c/f17d59/32.png) [@caccola816](https://brian.discourse.group/u/caccola816)\
**Post date:** [14 January 2023 17:58 UTC](https://brian.discourse.group/t/about-network-class/864/1 "2023-01-14T17:58:12Z")

</div>

Hello! I am trying to use the Network class to perform multiple simulations. I created a function Model() in which i defined NeuronGroups and Synapses. Model() return Network(NeuronGroups, Synapses). Reading the Network source code I found that if I want to access to an object inside the Network class i need to call (if `net = Model()`) `net['NeuronGroup']` but it is not working.

```python
def Model():
   thalamus = NeuronGroup()
   crtx = NeuronGroup()
   S = Synapses(thalamus, crtx)
   return(Network(collect()))

net = Model()
input=PoissonGroup()
S2 = Synapses(input, net['thalamus'])

```

and here i get the error KeyError: ‘No object with name “thalamus” found’

I initially thought was a namespace problem (it could be right?) but it doesn’t work even if i define a dummy neuron, add it to the net and try to access it.

```python
dummy_neuron = NeuronGroup(1,....)
net.add(dummy_neuron)
net['dummy_neuron']

```

KeyError: ‘No object with name “dummy\_neuron” found’

So i would like to know: How can i access to the Network objects and if i can use a single instance of Network() in multiple functions and saving step by step the state of the network

---

<div class="post-metadata">

**Author:** ![mstimberg](https://yyz2.discourse-cdn.com/free1/user_avatar/brian.discourse.group/mstimberg/32/11_2.png) [@mstimberg](https://brian.discourse.group/u/mstimberg)\
**Post date:** [16 January 2023 11:16 UTC](https://brian.discourse.group/t/about-network-class/864/2 "2023-01-16T11:16:51Z")

</div>

Hi @caccola816. The basic idea is correct, but you need to use the `name` of the object, which isn’t the name of the _variable_ you used when you created the object. In your example, the `Network` does not know that your `NeuronGroup` was stored in a variable `thalamus`, and it could not have been stored in any variable at all, but instead in a list or something similar.  
This is why each object in Brian also has an internal name that is used in a few places. By default, in both of your example, this name would be `neurongroup` (if there is more than one object, it would be `neurongroup_2`, etc.). But if you want to refer for it, and for easier debugging, I’d strongly recommend that you specify the name manually:

```python
thalamus = NeuronGroup(..., name='thalamus')

```

You should then be able to access the object via `net['thalamus']`.

Hope that clears things up!

---

<div class="post-metadata">

**Author:** ![caccola816](https://avatars.discourse-cdn.com/v4/letter/c/f17d59/32.png) [@caccola816](https://brian.discourse.group/u/caccola816)\
**Post date:** [17 January 2023 14:01 UTC](https://brian.discourse.group/t/about-network-class/864/3 "2023-01-17T14:01:10Z")

</div>

Oh ok, perfect! Thank you!
