inincs / pyNCS

pyNCS is a python library that allows easy access to Neuromorphic Chips and Systems (NCS),
http://inincs.github.com/pyNCS/
GNU General Public License v2.0
16 stars 10 forks source link

1-to-n connectivity #14

Closed aamirsyed closed 11 years ago

aamirsyed commented 11 years ago

I have been trying to implement a connectivity pattern where first neuron of population A connects to neuron 1:5 of population B, second neuron (from pop. A) connects to 3:6, third to 5:8 and so on - essentially a 1-to-n connectivity.

To implement I thought of an appropriate 'fashion', and I can see a few of them defined in the source file. Since this is a bit specific, I chose one-to-one, and made the connections separately by a loop where each connection (neuron in a population) would be picked separately. To check if it works, I initially define an src and dest populations of five neurons

my_pop.populate_by_number( nsetup, 'ifslwta', 'excitatory', 5) input_pop.populate_by_number(nsetup, 'seq', 'excitatory', 5)

and then made the connection for only two (just to test it):

C = pyNCS.Connection(input_pop[0], my_pop[1], 'excitatory0','one2one') C1 = pyNCS.Connection(input_pop[0], my_pop[2], 'excitatory0','one2one')

But it does not seem to pick up swiftly for the second connection (C1) connection (at mapping.merge).

I need some suggestion if another fashion would make more sense, (e.g. _connect_by_binarymatrix etc.) or some other quick fix to the problem. Do we have examples for matrix connectivities?

LOG:

ValueError Traceback (most recent call last) /usr/lib/python2.7/dist-packages/IPython/utils/py3compat.pyc in execfile(fname, where) 173 else: 174 filename = fname --> 175 builtin.execfile(filename, where)

/homes/saamir/git/fishmorph/experiments/ellTest2/expRun.py in () 2 3 from pylab import ----> 4 from expMap import 5 from expStim import 6 #from expPlot import

/homes/saamir/git/fishmorph/experiments/ellTest2/expMap.py in () 6 7 C = pyNCS.Connection(input_pop[0], my_pop[1], 'excitatory0','one2one') ----> 8 C1 = pyNCS.Connection(input_pop[0], my_pop[2], 'excitatory0','one2one') 9 print "pyMap clear!" 10

/homes/saamir/.local/lib/python2.7/site-packages/pyNCS/connection.pyc in init(self, popsrc, popdst, synapse, fashion, fashion_kwargs, append, setup) 38 setup = popsrc.setup 39 if append: ---> 40 setup.mapping.merge(self.mapping) 41 42 self.synapse = synapse

/homes/saamir/.local/lib/python2.7/site-packages/pyNCS/mapping.pyc in merge(self, pyncs_mapping) 96 if len(pyncs_mapping.mapping) > 0: 97 self.mapping = np.concatenate([self.mapping, ---> 98 pyncs_mapping.mapping]).tolist() 99 else: 100 self.mapping = pyncs_mapping.mapping

ValueError: array dimensions must agree except for d_0


fabioedoardoluigialberto commented 11 years ago

Hi

regarding the example code, try the following:

C = pyNCS.Connection(input_pop[0:1], my_pop[1:2], 'excitatory0','one2one')
C1 = pyNCS.Connection(input_pop[0:1], my_pop[2:3], 'excitatory0','one2one')

However for the more general case you are trying to implement I think the use of the binary matrix is more elegant.

Edit: untrue, use all2all instead. See comments below.

Fabio

sheiksadique commented 11 years ago

I am almost certain the problem is because the mapper you are using supports probability and the function you are using to initiate connections was originally written for non probabilistic connections. (I will have to verify this).

In the mean time, try using PConnection instead of Connection and let us know if that fixes the problem.

aamirsyed commented 11 years ago

Hi all, and thanks,

The [0:1], [1:2] approach gives a similar error: "array dimensions must agree except for d_0"

However, the PConnection compiles the code! Is it possible to get an example of binary matrix.

aamirsyed commented 11 years ago

I was just looking into documentation, and wondered if one has a control over the probability?

http://inincs.github.com/pyNCS/general/pyNCS.html#pyNCS.connection.Connection

Further, what other functions are affected? How can one ensure and know our mapper features?

sheiksadique commented 11 years ago

Unfortunately there is no easy way to find out which types of connection 'fashions' you have available to you.

The easiest way to inspect which fashions you have available to you is by doing the following

once you have initialized the NeuroSetup for your experimental setup in ipython do the following

$ setup.mapping.__connect_<tab>
  pyNCS.Mapping.__connect_all2all__                pyNCS.Mapping.__connect_by_probability_matrix__   pyNCS.Mapping.__connect_shuffle_all2all__
  pyNCS.Mapping.__connect_by_arbitrary_matrix__    pyNCS.Mapping.__connect_one2one__                
  pyNCS.Mapping.__connect_by_binary_matrix__       pyNCS.Mapping.__connect_random_all2all__ 

The above are the functions that are internally available when you use any given fashion. For eg. when you want to use fashion='one2one', internally the function connect_one2one is called. To know any further arguments that you need to pass to this function through fashion_kwargs, you can do the following:

$ setup.mapping.__connect_<fashion>__ ?
   Type:       instancemethod
String Form:<unbound method Mapping.__connect_by_arbitrary_matrix__>
File:       /usr/local/lib/python2.7/dist-packages/pyNCS/mapping.py
Definition: pyNCS.Mapping.__connect_by_arbitrary_matrix__(self, groupsrc, groupdst, M, resize_method='resample', expand=True, hide=False)
Docstring:  <no docstring>

The arguments you need to pass to your Connection for a given fashion through fashion_kwargs are the arguments you see in the above function call. For the above example the arguments that you need to send would be

fashion_kwargs = {'M':[<two dimensional matrix describing your connectivity>],
                            'resize_method':'resample',}

Hope that helps.. In the mean time, we will try and fix the bug and update the documentation about this stuff. And ofcourse thanks for reporting the bug !

aamirsyed commented 11 years ago

and thanks for the tips, useful they are!

fabioedoardoluigialberto commented 11 years ago

Hi,

for 1-to-N connectivity actually the easiest way is to use all2all and use a population of one neuron as the src:

C = pyNCS.Connection(input_pop[:1], my_pop[:2], 'excitatory0', 'all2all')

Sorry for the confusion.