loopConnections = list() for i in range(0, nNeurons): singleConnection = (i, ((i + 1) % nNeurons), weight_to_spike, delay) loopConnections.append(singleConnection) injectionConnection = [(0, 0, weight_to_spike, 1)] spikeArray = {'spike_times': [[0]]} populations.append( p.Population(nNeurons, p.IF_curr_exp, cell_params_lif, label='pop_1')) populations.append( p.Population(1, p.SpikeSourceArray, spikeArray, label='inputSpikes_1')) projections.append( p.Projection(populations[0], populations[0], p.FromListConnector(loopConnections))) projections.append( p.Projection(populations[1], populations[0], p.FromListConnector(injectionConnection))) populations[0].record_v() populations[0].record_gsyn() populations[0].record(visualiser_mode=modes.RASTER) p.run(5000) v = None gsyn = None spikes = None v = populations[0].get_v(compatible_output=True)
sim.Projection(INoisePre, pre_pop, ee_connector, target='excitatory') sim.Projection(INoisePost, post_pop, ee_connector, target='excitatory') # Additional Inputs projections for i in range(len(IAddPre)): sim.Projection(IAddPre[i], pre_pop, ee_connector, target='excitatory') for i in range(len(IAddPost)): sim.Projection(IAddPost[i], post_pop, ee_connector, target='excitatory') # Plastic Connections between pre_pop and post_pop stdp_model = sim.STDPMechanism( timing_dependence = sim.SpikePairRule(tau_plus = 20., tau_minus = 50.0, nearest=False), weight_dependence = sim.AdditiveWeightDependence(w_min = 0, w_max = 4.5, A_plus=0.02, A_minus = 0.02) ) conn=sim.FromListConnector([[i,i,.05,1.0] for i in range(pop_size)]) plastic_projection = \ sim.Projection(pre_pop, post_pop, conn, #sim.FixedProbabilityConnector(p_connect=0.5,weights=0.01,delays=1.0), synapse_dynamics = sim.SynapseDynamics(slow= stdp_model) ) # +-------------------------------------------------------------------+ # | Simulation and results | # +-------------------------------------------------------------------+ # Record neurons' potentials pre_pop.record_v() post_pop.record_v() # Record spikes
delays = list() loopConnections = list() for i in range(0, nNeurons): d_value = int(delay.uniform(low=1, high=max_delay)) delays.append(float(d_value)) singleConnection = (i, ((i + 1) % nNeurons), weight_to_spike, d_value) loopConnections.append(singleConnection) injectionConnection = [(0, 0, weight_to_spike, 1)] spikeArray = {'spike_times': [[0]]} populations.append(p.Population(nNeurons, p.IF_curr_exp, cell_params_lif, label='pop_1')) populations.append(p.Population(1, p.SpikeSourceArray, spikeArray, label='inputSpikes_1')) #populations[0].set_mapping_constraint({"x": 1, "y": 0}) projections.append(p.Projection(populations[0], populations[0], p.FromListConnector(loopConnections))) projections.append(p.Projection(populations[1], populations[0], p.FromListConnector(injectionConnection))) populations[0].record_v() populations[0].record_gsyn() populations[0].record(visualiser_mode=modes.RASTER) run_time = (max_delay * nNeurons) print "Running for {} ms".format(run_time) p.run(run_time) v = None gsyn = None spikes = None v = populations[0].get_v(compatible_output=True)
#input_pol_2.set_mapping_constraint({'x':1,'y':0}) # this is where the sensor is going to be actually mapped in the NN subsampled = p.Population( subsample_size * subsample_size, # size p.IF_curr_exp, # Neuron Type cell_params_subsample, # Neuron Parameters label="Input") # Label subsampled.initialize('v', -75) subsampled.set_mapping_constraint({'x': 0, 'y': 1}) #subsampled.record() # sends spikes to the visualiser (use parameters = 32) p1_up = p.Projection(input_pol_1_up, subsampled, p.FromListConnector( retina_lib.subSamplerConnector2D( 128, subsample_size, .2, 1)), label='subsampling projection') p1_down = p.Projection(input_pol_1_down, subsampled, p.FromListConnector( retina_lib.subSamplerConnector2D( 128, subsample_size, .2, 1)), label='subsampling projection') p2_up = p.Projection(input_pol_2_up, subsampled, p.FromListConnector( retina_lib.subSamplerConnector2D( 128, subsample_size, .2, 1)), label='subsampling projection') p2_down = p.Projection(input_pol_2_down,
p.Population(100, p.IF_curr_exp, cell_params_lif, label='pop_13')) populations[12].set_mapping_constraint({'x': 0, 'y': 0}) populations.append( p.Population(100, p.IF_curr_exp, cell_params_lif, label='pop_14')) populations[13].set_mapping_constraint({'x': 0, 'y': 0}) populations.append( p.Population(100, p.IF_curr_exp, cell_params_lif, label='pop_15')) populations[14].set_mapping_constraint({'x': 0, 'y': 0}) populations.append( p.Population(100, p.IF_curr_exp, cell_params_lif, label='pop_16')) populations[15].set_mapping_constraint({'x': 4, 'y': 3}) projections.append( p.Projection(populations[0], populations[15], p.FromListConnector(injectionConnection))) projections.append( p.Projection(populations[1], populations[15], p.FromListConnector(injectionConnection))) projections.append( p.Projection(populations[2], populations[15], p.FromListConnector(injectionConnection))) projections.append( p.Projection(populations[3], populations[15], p.FromListConnector(injectionConnection))) projections.append( p.Projection(populations[4], populations[15], p.FromListConnector(injectionConnection))) projections.append( p.Projection(populations[5], populations[15], p.FromListConnector(injectionConnection)))
'connected_chip_edge': link, 'polarity': p.ExternalFPGARetinaDevice.DOWN_POLARITY}, label='External retina')) ''' #loopConnections = list() #for i in range(0, 1): # singleConnection = (i, ((i + 1) % 1), 1, 1) # loopConnections.append(singleConnection) populations.append( p.Population(1024, p.IF_curr_exp, cell_params_lif, label='pop_1')) projections.append( p.Projection( populations[0], populations[2], p.FromListConnector(retina_lib.subSamplerConnector2D(128, 32, .2, 1)))) projections.append( p.Projection( populations[1], populations[2], p.FromListConnector(retina_lib.subSamplerConnector2D(128, 32, .2, 1)))) populations[0].record(visualiser_mode=modes.TOPOLOGICAL, visualiser_2d_dimension={ 'x': 128, 'y': 128 }) populations[1].record(visualiser_mode=modes.TOPOLOGICAL, visualiser_2d_dimension={ 'x': 128, 'y': 128 })