Efficient Connections

17 views
Skip to first unread message

Ajit Limaye

unread,
Jul 15, 2020, 6:18:36 PM7/15/20
to Brian
This is a toy example, but it captures the essence of my question. Given the following representative code:

G = SpikeGeneratorGroup(16,[],[]*ms)
N
= NeuronGroup(16,eqs, threshold='v>-.55', reset='v = -.7')
S
= Synapses(G,N)

. . . if I want to make an all-to-all synaptic connection from G[2,3,4,5] to N[10,11,12,13,14], is one of the following any more or less efficient than the other:

S.connect(i=[ii for ii in range(2,6)],j=[jj for jj in range(10,15)])
S
.connect(condition='i>1 and i<6 and j>9 and j<15')


. . . or are they equally efficient?

Is there a better way that I haven't thought of?

Thanks.

Vigneswaran

unread,
Jul 16, 2020, 4:41:20 AM7/16/20
to Brian
Hi,
     I guess, there won't be a much difference in efficiency-wise, because when you give the indices as an array, it is directly converted to `NumPy` array and when the condition string is given, arrays 'i' and 'j' are constructed from that.

Thanks,
Vigneswaran

aji...@comcast.net

unread,
Jul 16, 2020, 8:45:42 PM7/16/20
to brians...@googlegroups.com

Hi Vigneswaran:

 

A statement of the form “S.connect(i=[0,1,2],j=[10,11,12]) will not give a all-to-all connection (i.e. a total of 9 synapses). Instead, it will create 3 synapses (0,10),(1,11) and (2,12). The problem I am trying to solve is to create an all-to-all connection (with probability p) between non-contiguous groups in G and N. Is that possible? If so, how?

 

Thanks.

--
http://www.facebook.com/briansimulator
https://twitter.com/briansimulator
 
Please cite Brian 2: Stimberg M, Brette R, Goodman DFM (2019). Brian 2, an intuitive and efficient neural simulator. eLife, doi: 10.7554/eLife.47314.
---
You received this message because you are subscribed to the Google Groups "Brian" group.
To unsubscribe from this group and stop receiving emails from it, send an email to briansupport...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/briansupport/bcc7fa0c-10dc-4f05-b4ac-b86b3a367ddfn%40googlegroups.com.

Ajit Limaye

unread,
Jul 16, 2020, 10:01:05 PM7/16/20
to Brian
I tried an experiment to connect 10000 spike generators to 10000 neurons (all-to-all), using the following code:

from brian2 import *
import cv2
from datetime import datetime

tau
= 2*ms
eqs
= '''
dv/dt = (-.6-v)/tau : 1 (unless refractory)
'''


def go():
    N
= NeuronGroup(100000,eqs,threshold='v=-.55',reset='v=-.7',refractory=2*ms)
   
Sg = SpikeGeneratorGroup(100000,[],[]*ms)
    S
= Synapses(Sg,N,model='w:1')

    x
= [i for i in range(10000) for j in range(10000)]
    y
= [j for i in range(10000) for j in range(10000)]

    start
= datetime.now()
   
#S.connect(i=x,j=y)
    S
.connect(condition='i < 10000 and j < 10000')
   
end = datetime.now()
    elapsed
= (end-start).microseconds/1e3
   
print("Time to connect = %.4f milliseconds" % elapsed)
Enter code here...

with the first S.connect() call uncommented, the elapsed time was 514 ms, and with the second S.connect() call uncommented, the elapsed time was 830 ms. So it would seem that the first method - building two arrays to control all-to-all connection - is faster, but not by much.

Ajit

Vigneswaran

unread,
Jul 17, 2020, 12:09:17 AM7/17/20
to Brian
Hi Ajit,

      To create all-to-all synapse connections with probability `p`, you shall simply write,
S.connect(p = p_value)

Documentation link: Creating synaptic connections

Thanks,
Vigneswaran
Reply all
Reply to author
Forward
0 new messages