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

Resetting the biases to default initial conditions #26

Closed r-harsha closed 9 years ago

r-harsha commented 9 years ago

In my experiments, I am running the simulations in a loop for a different stimuli. When I tried to run the loop for the same stimuli for n times, the charge gets buildup on the DPI capacitor, especially when my currents are small and slow. I would like to reset the cap, for my every run and I tried many possibilities within the loop(marked with #tags in my code), but nothing worked out except when I actually exit my ipython shell. So is there any better way of doing this with inbuilt functions? I attached a raster showing my simulations for the same stimuli for different runs. newproblem

This is my code...

i=0 k=1 while i<=size(dBurst)-1: j=0 while j<=size(pBurst)-1:

    nsetup.chips['ifslwta0'].load_parameters('biases/defaultBiases_ifslwta_cricket')

    nsetup.chips['if2dwta0'].load_parameters('biases/defaultBiases_if2dwta')

    nsetup.chips['if2dwta1'].load_parameters('biases/defaultBiases_if2dwta')

    nsetup.chips['ifslwta0'].set_parameters(biases_ifslwta0) #setting biases for each run
    nsetup.chips['if2dwta0'].set_parameters(biases_if2dwta0) #setting biases for each run
    nsetup.chips['if2dwta1'].set_parameters(biases_if2dwta1) #setting biases for each run

    nBurst = (burst_period+(burst_period%(dBurst[i]+pBurst[j])))/(dBurst[i]+pBurst[j]) #decides the no. of pulses and pauses within 250 ms period
    while (nBurst*(dBurst[i]+pBurst[j]))-pBurst[j] <= burst_period:
        nBurst = nBurst+1
    nBurst = nBurst-1

    t, rates = create_bursts(fBurst,dBurst[i],pBurst[j],nBurst,nNeu) #passing arguments (fBurst,dBurst,pBurst,nBurst,nNeu)
    print 'nBurst:', nBurst
    stStim=pop_input.soma.spiketrains_inh_generator(rates,t,base_generator=pyST.STCreate.regular_generator)
    out=nsetup.stimulate(stStim)
    nsetup.run(stStim, duration=(nBurst*(dBurst[i]+pBurst[j])))
Here comes the part that I tried so far
    #l=0

    #while l<=size(pBurst)-1:

     #     t2, rates2 = create_bursts(fBurst,300,300,10,len(pop_input2)) #passing arguments (fBurst,dBurst,pBurst,nBurst,nNeu)
     #     stStim2=pop_input2.soma.spiketrains_inh_generator(rates2,t2,base_generator=pyST.STCreate.regular_generator)
     #     out=nsetup.stimulate(stStim2)
     #     nsetup.run(stStim2, duration=(10*(300+300)))
     #     l=l+1

    #nsetup.mapper.clear_mappings()

    #print "START TIME: %s" % time.ctime()
    #time.sleep(60)
    #print "END TIME : %s" % time.ctime()

    #resetbiases_if2dwta0 = { 'psynaerexctau0': 0,  # Time constant exc0 (AN1b synapse) #2.95>>>>>>>>>>
    #                         'psynaerexctau1': 0,
                           }

    #resetbiases_if2dwta1 = { 'psynaerexctau0': 0,  # Time constant exc0 (AN1b synapse) #2.95>>>>>>>>>>
    #                         'psynaerexctau1': 0,
                           }

    #resetbiases_ifslwta0 = { 'psynstdtau': 0,  # Time constant exc0 (AN1b synapse) #2.95>>>>>>>>>>
    #                  }

    #nsetup.chips['ifslwta0'].set_parameters(resetbiases_ifslwta0) #setting biases for each run
    #nsetup.chips['if2dwta0'].set_parameters(resetbiases_if2dwta0) #setting biases for each run
    #nsetup.chips['if2dwta1'].set_parameters(resetbiases_if2dwta1) #setting biases for each run

    #nsetup.prepare() # Apply the mapping and prepare the network

    j=j+1
    k=k+1

i=i+1
fabioedoardoluigialberto commented 9 years ago

Hi Harsha,

you seem to refer to a specific issue of your electronic circuits for the particular experiment you want to run. I doubt it has anything to do with IPython... Have tried pausing between loops?

import time
...
for i in range(n_times):
    # your stimulation here
    time.sleep(5)  # pauses 5 seconds

An other way would be to set the time constants of your circuits very fast for a brief moment at the end of each run in the loop, and then put it back to their values.

Thanks for posting.

Fabio

fabioedoardoluigialberto commented 9 years ago

Sorry, I overlooked the code you reported.

You do seem to have tried the sleep function. Can you report more details of what happens in that case?

You should also make sure that you are reloading all the biases of the initial conditions within each iteration. Closing and exciting IPython forces you to re-run the bias settings so that's probably why the experiment works again.

r-harsha commented 9 years ago

Hi Fabio,

No problem :) Nothing really changes when I introduced my sleep function even for a minute! If sleep for a while is a problem, then how could it work normally when I restart my Ipython shell in seconds?

If you look at the beginning of my loop, I do reload all my biases to default_biases which is my initial conditions and then I am applying my regular biases. But as you see, this problem is prominant only for those with small weight and really slow timeconstant!

Do you think that I missed something there?

r-harsha commented 9 years ago

I think I just figured out the problem. It was the timeconstant of the short term depression circuit(which I didn't mention earlier, sorry!!!), which is really slow and I need to reset them, instead of DPI timeconstant alone.

Thanks again for your support Fabio :+1: