def test_partitioning(self): p1 = sim.Population(5, sim.IF_cond_exp()) p2 = sim.Population(7, sim.IF_cond_exp()) a = p1 + p2[1:4] # [0 2 3 4 5][x 1 2 3 x x x] prj = sim.Projection(a, a, MockConnector(), synapse_type=self.syn) presynaptic_indices = numpy.array([0, 3, 4, 6, 7]) partitions = prj._partition(presynaptic_indices) self.assertEqual(len(partitions), 2) assert_array_equal(partitions[0], numpy.array([0, 3, 4])) assert_array_equal(partitions[1], numpy.array([2, 3])) # [0 1 2 3 4][x 1 2 3 x] self.assertEqual(prj._localize_index(0), (0, 0)) self.assertEqual(prj._localize_index(3), (0, 3)) self.assertEqual(prj._localize_index(5), (1, 1)) self.assertEqual(prj._localize_index(7), (1, 3))
weight_ini = 0.16 # define the initial value of the input signal weight run_time = 500 # define the simulation time per run sim.setup() # ==========generate OR read in the input spikes data===================== Excinp = sim.Population(Exc_in, sim.SpikeSourcePoisson(rate=15)) Inhinp = sim.Population(Inh_in, sim.SpikeSourcePoisson(rate=15)) # ==========create neuron population===================== # todo: the initail parameters of neurons might be modified cell_type_parameters = {'tau_refrac': 0.1, 'v_thresh': -50.0, 'tau_m': 20.0, 'tau_syn_E': 0.5, 'v_rest': -65.0,\ 'cm': 1.0, 'v_reset': -65.0, 'tau_syn_I': 0.5, 'i_offset': 0.0} # print(sim.IF_curr_alpha.default_parameters) cell_type = sim.IF_cond_exp(** cell_type_parameters) # neuron type of population Pexc = sim.Population( N_e, cell_type, label="excitotary neurons") # excitatory neuron population Pinh = sim.Population( N_i, cell_type, label="inhibitatory neurons") # inhibitoty neuron population all_cells = sim.Assembly( Pexc, Pinh ) # assembly for all neuron population for the purpose of data recording # todo: the Population structure # ==========create neuron connection====================== # the network topology is based on 'compensating inhomogeneities of neuromorphic VLSI devices via short-term synaptic plasticity' # todo: generate a concrete connection probability and weight (not chaged for each run)
import pyNN.brian as sim sim.setup() p = sim.Population(5, sim.IF_cond_exp()) p.set(tau_m=15.0) print(p.get('tau_m')) p[0, 2, 4].set(tau_m=10) print(p.get('tau_m')) print(p[0].tau_m) #random value from pyNN.random import RandomDistribution, NumpyRNG gbar_na_distr = RandomDistribution('normal', (20.0, 2.0), rng=NumpyRNG(seed=85524)) p = sim.Population(7, sim.HH_cond_exp(gbar_Na=gbar_na_distr)) print(p.get('gbar_Na')) print(p[0].gbar_Na) #setting from an array import numpy as np p = sim.Population(6, sim.SpikeSourcePoisson(rate=np.linspace(10.0, 20.0, num=6))) print(p.get('rate')) #using function to calculate from numpy import sin, pi p = sim.Population(8, sim.IF_cond_exp(i_offset=lambda i: sin(i * pi / 8))) print(p.get('i_offset'))
w1_2 = 0.1 w2_1 = 0.1 w2_2 = 0.1 # set up the classifier network for i in range(len(training_label)): # for i in range(1): lg.info('iteration number %d' % i) sim.setup() In_1 = sim.Population( 10, sim.SpikeSourcePoisson(rate=source_rate[training_label[i]])) In_2 = sim.Population( 10, sim.SpikeSourcePoisson(rate=source_rate[1 - training_label[i]])) In = In_1 + In_2 Out_1 = sim.Population(10, sim.IF_cond_exp()) Out_2 = sim.Population(10, sim.IF_cond_exp()) Out = Out_1 + Out_2 syn_1_1 = sim.StaticSynapse(weight=w1_1, delay=0.5) syn_1_2 = sim.StaticSynapse(weight=w1_2, delay=0.5) syn_2_1 = sim.StaticSynapse(weight=w2_1, delay=0.5) syn_2_2 = sim.StaticSynapse(weight=w2_2, delay=0.5) prj_1_1 = sim.Projection(In_1, Out_1, sim.ArrayConnector(connector1_1), syn_1_1, receptor_type='excitatory') prj_1_2 = sim.Projection(In_1, Out_2,
import pyNN.brian as sim import numpy as np training_data = np.loadtxt('training_data_0_1.txt', delimiter=',') training_label = training_data[:, -1] training_rate = training_data[:, 0:64] # print training_rate[1, :] inputpop = [] sim.setup() for i in range(np.size(training_rate, 1)): inputpop.append( sim.Population(1, sim.SpikeSourcePoisson(rate=abs(training_rate[0, i])))) # print inputpop[0].get('rate') # inputpop[0].set(rate = 8) # print inputpop[0].get('rate') pop = sim.Population(1, sim.IF_cond_exp(), label='exc') prj1 = sim.Projection(inputpop[0], pop, sim.OneToOneConnector(), synapse_type=sim.StaticSynapse(weight=0.04, delay=0.5), receptor_type='inhibitory') print prj1.get('weight', format='list')