def runTest(self): import numpy import pyNN.hardware.brainscales as pynn # set-up the simulator pynn.setup( timestep=0.1, useSystemSim=True, speedupFactor=8000, ignoreDatabase=True, ignoreHWParameterRanges=True, hardware=pynn.hardwareSetup['one-hicann'], ) # Set the neuron model class neuron_model = pynn.IF_cond_exp # I&F neuron_parameters = { 'cm': 0.281, # membrane capacitance nF 'e_rev_E': 0.0, # excitatory reversal potential in mV 'e_rev_I': -50.0, # inhibitory reversal potential in mV (HIGHER THAN v_thresh) 'i_offset': 0.0, # offset current 'tau_m': 9.3667, # membrane time constant 'tau_refrac': 1.0, # absolute refractory period 'tau_syn_E': 5.0, # excitatory synaptic time constant 'tau_syn_I': 5.0, # inhibitory synaptic time constant 'v_reset': -70.6, # reset potential in mV 'v_rest': -70.6, # resting potential in mV 'v_thresh': -55., # spike initiaton threshold voltage in mV } # We create a Population with 1 neuron of our N1 = pynn.Population(size=1, cellclass=neuron_model, cellparams=neuron_parameters) spiketimes = numpy.arange(10., 60., 5.) S1 = pynn.Population(1, pynn.SpikeSourceArray, cellparams={'spike_times': spiketimes}) pynn.Projection(S1, N1, pynn.AllToAllConnector(weights=0.010425507084882381), target='excitatory') # max weight in hardware # record the voltage of all neurons of the population N1.record() # run the simulation for 200 ms pynn.run(80.) spikes = N1.getSpikes() pynn.end() self.assertEqual( spikes.shape, (3, 2), "Number of spikes is not as expected") # should have 3 spikes!!
def test_restart_loop(): extra = {"loglevel": 0, "useSystemSim": True, "hardware": sim.hardwareSetup["one-hicann"]} sim.setup(**extra) sim.end() sim.setup(**extra) sim.end() sim.setup(**extra) sim.run(10.0) sim.end() sim.setup(**extra) sim.run(10.0) sim.end()
def test_restart_loop(): extra = { 'loglevel': 0, 'useSystemSim': True, 'hardware': sim.hardwareSetup['one-hicann'] } sim.setup(**extra) sim.end() sim.setup(**extra) sim.end() sim.setup(**extra) sim.run(10.0) sim.end() sim.setup(**extra) sim.run(10.0) sim.end()
def run_experiment(self, weight_distortion=None): import pyNN.hardware.brainscales as pynn setup_params = dict( useSystemSim=True, ignoreDatabase=True, ignoreHWParameterRanges=True, hardware=pynn.hardwareSetup["one-hicann"], rng_seeds=[123567], ) if weight_distortion is not None: setup_params['ess_params'] = { 'weightDistortion': weight_distortion } pynn.setup(**setup_params) num_neurons = 2 pop = pynn.Population(num_neurons, pynn.IF_cond_exp) # two different input spike trains, with identical rate but shifted to avoid loss in merger tree spike_times1 = np.arange(100., 500, 10.) spike_times2 = np.arange(105., 505, 10.) pop_source = pynn.Population(2, pynn.SpikeSourceArray) pop_source.tset('spike_times', [spike_times1, spike_times2]) weight = 0.1 # weight = pop[0].cell.getConductanceRange("weight")[1] conn = pynn.OneToOneConnector(weights=weight) proj_0 = pynn.Projection(pop_source, pop, conn) pop.record() pynn.run(600.) spikes = pop.getSpikes() spikes_nrn_0 = spikes[spikes[:, 0] == 0, 1] spikes_nrn_1 = spikes[spikes[:, 0] == 1, 1] pynn.end() return len(spikes_nrn_0), len(spikes_nrn_1)
def test_restart_loop(): if not have_hardware_brainscales: raise SkipTest extra = {'loglevel':0, 'useSystemSim': True, 'hardware': sim.hardwareSetup['one-hicann']} sim.setup(**extra) sim.end() sim.setup(**extra) sim.end() sim.setup(**extra) sim.run(10.0) sim.end() sim.setup(**extra) sim.run(10.0) sim.end() #def test_several_runs(): if not have_hardware_brainscales: raise SkipTest
def test_restart_loop(): if not have_hardware_brainscales: raise SkipTest extra = {'loglevel': 0, 'useSystemSim': True, 'hardware': sim.hardwareSetup['one-hicann']} sim.setup(**extra) sim.end() sim.setup(**extra) sim.end() sim.setup(**extra) sim.run(10.0) sim.end() sim.setup(**extra) sim.run(10.0) sim.end() # def test_several_runs(): if not have_hardware_brainscales: raise SkipTest
def tearDown(self): sim.end()
def test_end(self): sim.setup(**extra) sim.end() # need a better test
def runTest(self): import numpy import pyNN.hardware.brainscales as pynn # set-up the simulator pynn.setup( timestep=0.1, useSystemSim=True, speedupFactor=10000, ignoreDatabase=True, ignoreHWParameterRanges=True, hardware=pynn.hardwareSetup['one-hicann'], ) # Set the neuron model class neuron_model = pynn.IF_cond_exp # I&F neuron_parameters = { 'cm': 0.281, # membrane capacitance nF 'e_rev_E': 0.0, # excitatory reversal potential in mV 'e_rev_I': -100.0, # inhibitory reversal potential in mV 'i_offset': 0.0, # offset current 'tau_m': 9.3667, # membrane time constant 'tau_refrac': 1.0, # absolute refractory period 'tau_syn_E': 5.0, # excitatory synaptic time constant 'tau_syn_I': 5.0, # inhibitory synaptic time constant 'v_reset': -70.6, # reset potential in mV 'v_rest': -70.6, # resting potential in mV 'v_thresh': -55., # spike initiaton threshold voltage in mV } # We create a Population with 1 neuron of our N1 = pynn.Population(size=2, cellclass=neuron_model, cellparams=neuron_parameters) N1a = N1[0:1] N1b = N1[1:2] v_shift = 5. # shift all voltages of 2nd neuron by 5 mV N1b.set('v_rest', neuron_parameters['v_rest'] - v_shift) N1b.set('v_reset', neuron_parameters['v_reset'] - v_shift) N1b.set('v_thresh', neuron_parameters['v_thresh'] - v_shift) N1b.set('e_rev_E', neuron_parameters['e_rev_E'] - v_shift) N1b.set('e_rev_I', neuron_parameters['e_rev_I'] - v_shift) spiketimes = [10., 50., 110., 122.5] S1 = pynn.Population(1, pynn.SpikeSourceArray, cellparams={'spike_times': spiketimes}) pynn.Projection(S1, N1, pynn.AllToAllConnector(weights=0.0123938304114), target='inhibitory') # max weight in hardware # record the voltage of all neurons of the population N1.record_v() # run the simulation for 200 ms pynn.run(150.) # format of get_v: [id, t, v] mean_v_a = N1a.get_v().transpose()[2].mean() mean_v_b = N1b.get_v().transpose()[2].mean() self.assertAlmostEqual( mean_v_a, mean_v_b + v_shift, places=3, msg= 'The mean voltage of neuron a and b should have a difference of 5 mV' ) pynn.end()
def test_sim_without_setup(): if not have_hardware_brainscales: raise SkipTest sim.end()
def test_sim_without_setup(): sim.end()
def runTest(self): import numpy backend = "hardware.brainscales" import pyNN.hardware.brainscales as pynn # set-up the simulator pynn.setup( timestep=0.1, useSystemSim=True, speedupFactor=8000, ignoreDatabase=True, ignoreHWParameterRanges=True, hardware=pynn.hardwareSetup['one-hicann'], ) neuron_count = 1 # size of the Population we will create # Set the neuron model class neuron_model = pynn.EIF_cond_exp_isfa_ista # an Adaptive Exponential I&F Neuron neuron_parameters = { 'a' : 10.0, # adaptation variable a in nS 'b' : 0.0805, # adaptation variable b in pA 'cm' : 0.281, # membrane capacitance nF 'delta_T' : 2.0, # delta_T fom Adex mod in mV, determines the sharpness of spike initiation 'e_rev_E' : 0.0, # excitatory reversal potential in mV 'e_rev_I' : -100.0, # inhibitory reversal potential in mV 'i_offset' : 0.0, # offset current 'tau_m' : 9.3667, # membrane time constant 'tau_refrac' : 8.0, # absolute refractory period 'tau_syn_E' : 5.0, # excitatory synaptic time constant 'tau_syn_I' : 5.0, # inhibitory synaptic time constant 'tau_w' : 144.0, # adaptation time constant 'v_reset' : -70.6, # reset potential in mV 'v_rest' : -70.6, # resting potential in mV 'v_spike' : -40.0, # spike detection voltage in mV 'v_thresh' : -66.9, # spike initiaton threshold voltage in mV } # We create a Population with 1 neuron of our N1 = pynn.Population( size = 1, cellclass = neuron_model, cellparams = neuron_parameters) N1.initialize('v',neuron_parameters['v_rest']) spiketimes = numpy.arange(100.,800.,0.5) S1 = pynn.Population(1,pynn.SpikeSourceArray, cellparams = {'spike_times':spiketimes}) pynn.Projection(S1,N1,pynn.OneToOneConnector(weights=0.0123938304114), target='inhibitory') # max weight in hardware # record the spikes of all neurons of the population N1.record() # run the simulation for 500 ms pynn.run(1000.) num_spikes = 0 # After the simulation, we get Spikes and save the voltage trace to a file spike_times = N1.getSpikes() for pair in spike_times: print "Neuron ", int(pair[0]), " spiked at ", pair[1] num_spikes += 1 pynn.end() self.assertEqual(int(num_spikes),1,'The Neuron spiked more than once, i.e. there was a rebound burst, and not a single rebound spike as it should be')