# Description of problem

If I design spiking neural network where input is Poisson source,1st layer contain 10 neurons, hidden layer contains 20 neurons and output layer contains 5 neurons, if the synaptic connection probability is 0.2,we can easily find the spike times of each layer(input, hidden or output) neurons .But,
(Q1).Is there any way to observe or find interconnection of all neurons, means which source neurons are connected to which destination neurons in the next layer by the synapses(when synaptic connection probability p=0.2,as a result not all the neurons will be connected by synapses)?
(Q2) How can I find the number of spikes transmitted by any source neuron to its destination neuron through synapses, i.e, number of spikes transmitted by each active neuron ?

# from brian2 import * %matplotlib inline import numpy as np start_scope() N = 10 taum = 10ms Ee = 0mV vt = -50mV vr = -60mV El = -74mV taue = 5ms F = 15Hz we=(600.27/10) eqs_neurons = ‘’’ dv/dt = (ge * (Ee-v) + El - v) / taum : volt dge/dt = -ge / taue : 1 ‘’’ I= PoissonGroup(N, rates=F)#Input layer E10 = NeuronGroup(10, eqs_neurons, threshold=‘v>vt’, reset=‘v = vr’,method=‘euler’) E10.v=‘vr+rand()(vt-vr)’ E10.ge=0 S1=Synapses(I,E10,on_pre=‘ge += we’) S1.connect(p=0.2) #Hidden layer1 F10 = NeuronGroup(20, eqs_neurons, threshold=‘v>vt’, reset=‘v = vr’, method=‘euler’) F10.v='vr+rand()(vt-vr)’ F10.ge=0 S2= Synapses(E10,F10,on_pre=‘ge += we’) S2.connect(p=0.2)#Output layer G10= NeuronGroup(5, eqs_neurons, threshold=‘v>vt’, reset=‘v = vr’,method=‘euler’) G10.v='vr+rand()(vt-vr)’ G10.ge=0 S3=Synapses(F10,G10,on_pre=‘ge += we’) S3.connect(p=0.2) #INPUT LAYER K=SpikeMonitor(E10) #HIDDEN LAYER 1 L=SpikeMonitor(F10) #OUTPUT LAYER2 M=SpikeMonitor(G10) run(100ms, report=‘text’) What you have aready tried

#spike times of all the active neurons in the input layer
print(K.t)
#spike times of all the active neurons in the hidden layer
print(L.t)
#spike times of all the active neurons in the output layer
print(M.t)

NA

NA

# Full traceback of error (if relevant)

NA

Good morning, @lenovo1986

I’m also a new one here in Brian. But as far as I understood, in the SNN simulator “Brian2” units play a crucial role.
1.

``````N = 10
taum = 10*ms
Ee = 0*mV
vt = -50*mV
vr = -60*mV
El = -74*mV
taue = 5*ms
F = 15*Hz
``````

and also when we run, we should use

``````run(100*ms)
``````
``````print(K.t/ms)
print(L.t/ms)
print(M.t/ms)
``````
1. Could you explain why you’re using these followed lines:
``````E10.v='vr+rand()(vt-vr)'
F10.v='vr+rand()(vt-vr)'
G10.v='vr+rand()(vt-vr)'
``````
1. I hope I was correct. But I do not know. If I am wrong, I am sorry.
Good luck

P.S: @mstimberg told me that it is better to write your Python code under :

`````````Python
``````

Thanks:))

@assergazina: I believe the initialization is to simulate an approximate biological random voltage values of neurons, rather than having a value of 0 .

touches you are absolutely correct. It is used to show the randomness of the initial voltages of neurons ,which actually observed in the case of biological neurons.

1 Like

It is used to show the randomness of the initial voltages of neurons ,which actually observed in the case of biological neurons

Hi there!
@assergazina is right about code pasting – please put triple backticks around your code to avoid things like `*` being misinterpreted. Like so – highlight and click quote to see what this should look like in the post editor:

``````# code block here.
``````

As for connectivity structure, you can access that as follows (minimal code):

``````from brian2 import *
G = NeuronGroup(10, model='')
S = Synapse(G,G)
S.connect(p=0.1)
print(S.i_pre) # indices of the presynaptic units
print(S.i_post) # indices of the postsynaptic units
``````

There are a few other interesting properties; have a look at the output from `S.get_states()` - variable naming should be fairly self-explanatory.

Finally, the spikes transmitted will correspond to the presynaptic spikes, which you’re already collecting with `SpikeMonitor`s.

1 Like