当前位置: 首页>>代码示例>>Python>>正文


Python spiNNaker.run函数代码示例

本文整理汇总了Python中pyNN.spiNNaker.run函数的典型用法代码示例。如果您正苦于以下问题:Python run函数的具体用法?Python run怎么用?Python run使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了run函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

    def run( self ):
        print( "starting simulation. length: %d" % self.time )
        self.populations['pop1'].record()
        self.populations['pop2'].record()
        self.populations['pop3'].record()

        p.run( self.time )

        self.plot_spikes( populations['pop1'], "population 1" )
        self.plot_spikes( populations['pop2'], "population 2" )
        self.plot_spikes( populations['pop3'], "population 3" )
开发者ID:msil,项目名称:spinnaker-workshop,代码行数:11,代码来源:synfire_if_curr_exp6.py

示例2: main

def main():
    # setup timestep of simulation and minimum and maximum synaptic delays
    setup(timestep=simulationTimestep, min_delay=minSynapseDelay, max_delay=maxSynapseDelay, threads=4)

    # create a spike sources
    retinaLeft = createSpikeSource("Retina Left")
    retinaRight = createSpikeSource("Retina Right")
    
    # create network and attach the spike sources 
    network = createCooperativeNetwork(retinaLeft=retinaLeft, retinaRight=retinaRight)
    
    # run simulation for time in milliseconds
    print "Simulation started..."
    run(simulationTime)                                            
    print "Simulation ended."
    
    # plot results  
    plotExperiment(retinaLeft, retinaRight, network)
    # finalise program and simulation
    end()
开发者ID:AMFtech,项目名称:StereoMatching,代码行数:20,代码来源:CooperativeNetwork.py

示例3:

what_statement_gate.record()
who_query_gate.record()
who_query_gate.record_v()
who_query_gate.record_gsyn()
where_query_gate.record()
what_query_gate.record()

dst_who.record()
dst_where.record()
dst_what.record()

who.record()
where.record()
what.record()

p.run(10 * 1000)

# src_pop_spikes = src_pop.getSpikes(compatible_output=True)
# who_statement_gate_spikes = who_statement_gate.getSpikes(compatible_output=True)
# who_statement_gate_v = who_statement_gate.get_v()
# who_statement_gate_i = who_statement_gate.get_gsyn()
# where_statement_gate_spikes = where_statement_gate.getSpikes(compatible_output=True)
# what_statement_gate_spikes = what_statement_gate.getSpikes(compatible_output=True)
# who_query_gate_spikes = who_query_gate.getSpikes(compatible_output=True)
# who_query_gate_v = who_query_gate.get_v()
# who_query_gate_i = who_query_gate.get_gsyn()
# where_query_gate_spikes = where_query_gate.getSpikes(compatible_output=True)
# what_query_gate_spikes = what_query_gate.getSpikes(compatible_output=True)
# dst_who_spikes = dst_who.getSpikes(compatible_output=True)
# dst_where_spikes = dst_where.getSpikes(compatible_output=True)
# dst_what_spikes = dst_what.getSpikes(compatible_output=True)
开发者ID:pmhastings,项目名称:spikeparse,代码行数:31,代码来源:main.py

示例4:

p.get_db().set_number_of_neurons_per_core('IF_curr_exp', nNeurons)      # this will set 256 neurons per core

cell_params = {     'i_offset' : .1,    'tau_refrac' : 3.0, 'v_rest' : -65.0,
                    'v_thresh' : -51.0,  'tau_syn_E'  : 2.0,
                    'tau_syn_I': 5.0,    'v_reset'    : -70.0,
                    'e_rev_E'  : 0.,     'e_rev_I'    : -80.}

left_cochlea_ear = p.Population(nNeurons, p.ProxyNeuron, {'x_source':254, 'y_source':254}, label='left_cochlea_ear')
left_cochlea_ear.set_mapping_constraint({'x':0, 'y':0})
left_cochlea_ear.record()   #    this should record spikes from the cochlea


right_cochlea_ear = p.Population(nNeurons, p.SpikeSource, {}, label='right_cochlea_ear')
right_cochlea_ear = p.Population(nNeurons, p.ProxyNeuron, {'x_source':254, 'y_source':255}, label='left_cochlea_ear')
right_cochlea_ear.set_mapping_constraint({'x':0, 'y':0})

right_cochlea_ear.record()   #    this should record spikes from the cochlea

ifcell = p.Population(nNeurons, p.IF_curr_exp, cell_params, label='IF_curr_exp')
ifcell.record_v()

p1 = p.Projection(left_cochlea_ear, ifcell, p.OneToOneConnector(weights=1, delays=1), target='excitatory')
p2 = p.Projection(right_cochlea_ear, ifcell, p.OneToOneConnector(weights=1, delays=1), target='excitatory')

p.run(200.0)

p.end()


开发者ID:galluppf,项目名称:spackage_conv,代码行数:27,代码来源:cochlea_example.py

示例5: get_outgoing_edge_constraints

        AbstractOutgoingEdgeSameContiguousKeysRestrictor.__init__(self)

    def get_outgoing_edge_constraints(self, partitioned_edge, graph_mapper):
        constraints = AbstractOutgoingEdgeSameContiguousKeysRestrictor\
            .get_outgoing_edge_constraints(
                self, partitioned_edge, graph_mapper)
        constraints.append(KeyAllocatorFixedKeyAndMaskConstraint(
            [KeyAndMask(0x42000000, 0xFFFF0000)]))
        return constraints

    def is_virtual_vertex(self):
        return True

    def model_name(self):
        return "My External Device"


import pyNN.spiNNaker as p
from pacman.model.partitionable_graph.multi_cast_partitionable_edge \
    import MultiCastPartitionableEdge


p.setup(1.0)

device = p.Population(20, MyExternalDevice, {"spinnaker_link_id": 0},
                      label="external device")
pop = p.Population(20, p.IF_curr_exp, {}, label="population")
p.Projection(device, pop, p.OneToOneConnector())

p.run(10)
开发者ID:SpiNNakerManchester,项目名称:SpiNNakerManchester.github.io,代码行数:30,代码来源:advanced_external_devices_task_3.py

示例6:

spikeArray = {'spike_times': [[0, 1050]]}
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()

p.run(runtime)

v = None
gsyn = None
spikes = None

v = populations[0].get_v(compatible_output=True)
gsyn = populations[0].get_gsyn(compatible_output=True)
spikes = populations[0].getSpikes(compatible_output=True)

if spikes is not None:
    print spikes
    pylab.figure()
    pylab.plot([i[1] for i in spikes], [i[0] for i in spikes], ".")
    pylab.xlabel('Time/ms')
    pylab.ylabel('spikes')
开发者ID:SpikeFrame,项目名称:sPyNNaker,代码行数:31,代码来源:synfire_2_run_extraction_if_curr_exp_lower_second_run.py

示例7:

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()

p.run(526)
p.run(526)
p.run(526)
p.run(526)
p.run(526)
p.run(370)

v = None
gsyn = None
spikes = None

v = populations[0].get_v(compatible_output=True)
gsyn = populations[0].get_gsyn(compatible_output=True)
spikes = populations[0].getSpikes(compatible_output=True)

if spikes is not None:
开发者ID:SpikeFrame,项目名称:sPyNNaker,代码行数:31,代码来源:synfire_1_run_no_extraction_if_curr_exp_mapped_to_auto_pause.py

示例8: len

    if i == 1:
        projections.append(p.Projection(
            populations[i - 1], dual_stim_population, p.OneToOneConnector(
                weights=weight_to_spike, delays=10), target='excitatory'))
        projections.append(p.Projection(
            populations[i], dual_stim_population, p.OneToOneConnector(
                weights=weight_to_spike, delays=10), target='excitatory2'))
    if i > 0:
        projections.append(p.Projection(
            populations[i - 1], populations[i], p.OneToOneConnector(
                weights=weight_to_spike, delays=10)))

    populations[i].record_v()
    populations[i].record()

p.run(simulation_time)

id_accumulator = 0
colour_divider = 0x600 / n_pop
for i in range(n_pop):
    colour = 0x000000
    colour_scale = (i / 6) * colour_divider
    if (i % 6) < 2 or (i % 6) == 5:
        colour += 0xFF0000 - (colour_scale * 0x10000)
    if (i % 6) > 0 and (i % 6) < 4:
        colour += 0x00FF00 - (colour_scale * 0x100)
    if (i % 6) > 2:
        colour += 0x0000FF - colour_scale
    data = numpy.asarray(populations[i].getSpikes())
    if len(data) > 0:
        py_plot.scatter(
开发者ID:ruthvik92,项目名称:PyNNExamples,代码行数:31,代码来源:synfire_if_curr_dual_exp.py

示例9:

what_statement_gate.record()
who_query_gate.record()
who_query_gate.record_v()
who_query_gate.record_gsyn()
where_query_gate.record()
what_query_gate.record()

dst_who.record()
dst_where.record()
dst_what.record()

who.record()
where.record()
what.record()

p.run(15 * 1000)

src_pop_spikes = src_pop.getSpikes(compatible_output=True)
who_statement_gate_spikes = who_statement_gate.getSpikes(compatible_output=True)
who_statement_gate_v = who_statement_gate.get_v()
who_statement_gate_i = who_statement_gate.get_gsyn()
where_statement_gate_spikes = where_statement_gate.getSpikes(compatible_output=True)
what_statement_gate_spikes = what_statement_gate.getSpikes(compatible_output=True)
who_query_gate_spikes = who_query_gate.getSpikes(compatible_output=True)
who_query_gate_v = who_query_gate.get_v()
who_query_gate_i = who_query_gate.get_gsyn()
where_query_gate_spikes = where_query_gate.getSpikes(compatible_output=True)
what_query_gate_spikes = what_query_gate.getSpikes(compatible_output=True)
dst_who_spikes = dst_who.getSpikes(compatible_output=True)
dst_where_spikes = dst_where.getSpikes(compatible_output=True)
dst_what_spikes = dst_what.getSpikes(compatible_output=True)
开发者ID:pmhastings,项目名称:spikeparse,代码行数:31,代码来源:mainTxt.py

示例10: spike

# stimulate the first population with a single spike (3 times)
spike_times = [0, 1000, 2000]
in_0 = pynn.Population(1, pynn.SpikeSourceArray, {'spike_times': spike_times})

pynn.Projection(in_0, all_pops[0], con_alltoall, target="excitatory")


def shift(seq, n):
    n = n % len(seq)
    return seq[n:] + seq[:n]

# connect all populations, but don't close the chain
for pop_a, pop_b in zip(all_pops, shift(all_pops, 1)[:-1]):
    pynn.Projection(pop_a, pop_b, con_fixednumberpre, target='excitatory')

pynn.run(duration)

spikes = None

# Collect and record spikes
for pop in all_pops:
    new_spikes = pop.getSpikes(compatible_output=True)
    if new_spikes is not None:
        numpy.fliplr(new_spikes)
        new_spikes = new_spikes / [1, 1000.0]
        if spikes is None:
            spikes = new_spikes
        else:
            new_spikes = new_spikes + [len(spikes), 0]
            spikes = numpy.concatenate((spikes, new_spikes), axis=0)
if spikes is None:
开发者ID:electronicvisions,项目名称:hbp_platform_demo,代码行数:31,代码来源:run.py

示例11: open

                   'tau_syn_E' : 5.0,    #The excitatory input current decay time-constant
                   'tau_syn_I' : 5.0,    #The inhibitory input current decay time-constant
                   'v_reset'   : -70.0,  #The voltage to set the neuron at immediately after a spike
                   'v_rest'    : -65.0,  #The ambient rest voltage of the neuron
                   'v_thresh'  : -50.0    #The threshold voltage at which the neuron will spike.
                   }


stim_pop1 = p.Population(n_neurons, p.SpikeSourcePoisson,{"rate": 60.0,"start":0, "duration":50 } ) #Stimuluspopultn
ip_pop = p.Population(n_neurons, p.IF_curr_exp, cell_params_lif, label="inputneurons")


project_stim_pop_ip_pop = p.Projection( stim_pop1,ip_pop, p.OneToOneConnector(weights=10, delays=0.0), target="excitatory")

stim_pop1.record()
p.run(50)
spikes4 = stim_pop1.getSpikes()


with open('/home/ruthvik/Desktop/spikefile_800_50ms','w') as f:   ##make a pickle of spike data
    pickle.dump(spikes4,f)

spike_time4 = [i[1] for i in spikes4]
spike_id4 = [i[0] for i in spikes4]
pylab.plot(spike_time4, spike_id4, ".")
pylab.xlabel("Time (ms)")
pylab.ylabel("Neuron ID")
pylab.axis([0,50,0,800])
pylab.show()

开发者ID:ruthvik92,项目名称:spiNNaker-Codes.,代码行数:29,代码来源:poisn_50ms_patrn.py

示例12: max

grcpc_weights_distribution = p.RandomDistribution("uniform", [0.05, 0.5], rng)
pro_grcpcsynapsis_connector = p.FixedProbabilityConnector(0.8, weights=grcpc_weights_distribution)
pro_grcpcsynapsis_left = p.Projection(
    prepop,
    postpop,
    pro_grcpcsynapsis_connector,
    target="excitatory",
    synapse_dynamics=syndyn_grcpcsynapsis,
    label="grcpcsynapsis",
)

proj = pro_grcpcsynapsis_left
proj.projection_edge.postvertex.custom_max_atoms_per_core = max(1, 4000 / proj.projection_edge.prevertex.atoms)

# plasticsyn.projection_edge.postvertex.custom_max_atoms_per_core = 100
p.run(duration)
# IPython.embed()

prespikes = prepop.getSpikes()

if prespikes != None:
    plot(prespikes[:, 0], prespikes[:, 1], "gd", markersize=10, alpha=0.6)

teachspikes = teachpop.getSpikes()
if teachspikes != None:
    plot(teachspikes[:, 0], teachspikes[:, 1], "ro", markersize=10, alpha=0.6)

postspikes = postpop.getSpikes()
if postspikes != None:
    plot(postspikes[:, 0], postspikes[:, 1], "bs", markersize=10, alpha=0.6)
开发者ID:BRML,项目名称:HBP-spinnaker-cerebellum,代码行数:30,代码来源:minimal_learning.py

示例13: run_sim

    def run_sim(self):
        """
        Sets up and runs the simulation
        """
        num_neurons = 1471  # total neurons in network
        num_inputs = 14     # number of neurons considered inputs
        num_runs = 1        # number of times to loop the learning
        num_samples = 1     # number of samples to learn`
        sim_time = 1000.0    # time to run sim for`
        inhibitory_split = 0.2
        connection_probability_factor = 0.02
        plot_spikes = True
        save_figures = True
        show_figures = True
        sim_start_time = strftime("%Y-%m-%d_%H:%M")

        cell_params_lif = {'cm': 0.25, 'i_offset': 0.0, 'tau_m': 10.0, 'tau_refrac': 2.0, 'tau_syn_E': 3.0,
                           'tau_syn_I': 3.0, 'v_reset': -65.0, 'v_rest': -65.0, 'v_thresh': -50.0}

        # Create the 3d structure of the NeuCube based on the user's given structure file
        network_structure = NetworkStructure()
        network_structure.load_structure_file()
        network_structure.load_input_location_file()
        # Calculate the inter-neuron distance to be used in the small world connections
        network_structure.calculate_distances()
        # Generate two connection matrices for excitatory and inhibitory neurons based on your defined split
        network_structure.calculate_connection_matrix(inhibitory_split, connection_probability_factor)
        # Get these lists to be used when connecting the neurons later
        excitatory_connection_list = network_structure.get_excitatory_connection_list()
        inhibitory_connection_list = network_structure.get_inhibitory_connection_list()
        # Choose the correct neurons to connect them to, based on your a-priori knowledge of the data source -- eg, EEG
        # to 10-20 locations, fMRI to voxel locations, etc.
        input_neuron_indexes = network_structure.find_input_neurons()
        # Make the input connections based on this new list
        input_weight = 4.0
        input_connection_list = []
        for index, input_neuron_index in enumerate(input_neuron_indexes):
            input_connection_list.append((index, input_neuron_index, input_weight, 0))

        for run_number in xrange(num_runs):
            excitatory_weights = []
            inhibitory_weights = []
            for sample_number in xrange(num_samples):
                # At the moment with the limitations of the SpiNNaker hardware we have to reinstantiate EVERYTHING
                # each run. In future there will be some form of repetition added, where the structure stays in memory
                # on the SpiNNaker and only the input spikes need to be updated.

                data_prefix = sim_start_time + "_r" + str(run_number + 1) + "-s" + str(sample_number + 1)

                # Set up the hardware - min_delay should never be less than the timestep.
                # Timestep should = 1.0 (ms) for normal realtime applications
                p.setup(timestep=1.0, min_delay=1.0)
                p.set_number_of_neurons_per_core("IF_curr_exp", 100)

                # Create a population of neurons for the reservoir
                neurons = p.Population(num_neurons, p.IF_curr_exp, cell_params_lif, label="Reservoir")

                # Setup excitatory STDP
                timing_rule_ex = p.SpikePairRule(tau_plus=20.0, tau_minus=20.0)
                weight_rule_ex = p.AdditiveWeightDependence(w_min=0.1, w_max=1.0, A_plus=0.02, A_minus=0.02)
                stdp_model_ex  = p.STDPMechanism(timing_dependence=timing_rule_ex, weight_dependence=weight_rule_ex)
                # Setup inhibitory STDP
                timing_rule_inh = p.SpikePairRule(tau_plus=20.0, tau_minus=20.0)
                weight_rule_inh = p.AdditiveWeightDependence(w_min=0.0, w_max=0.6, A_plus=0.02, A_minus=0.02)
                stdp_model_inh  = p.STDPMechanism(timing_dependence=timing_rule_inh, weight_dependence=weight_rule_inh)

                # record the spikes from that population
                neurons.record('spikes')

                # Generate a population of SpikeSourceArrays containing the encoded input spike data
                # eg. spike_sources = p.Population(14, p.SpikeSourceArray, {'spike_times': [[]]})
                # for the moment I'm going to cheat and just use poisson trains as I don't have data with me
                spike_sources = p.Population(num_inputs, p.SpikeSourcePoisson, {'rate': rand.randint(20, 80)},
                                             label="Poisson_pop_E")

                # Connect the input spike sources with the "input" neurons
                connected_inputs = p.Projection(spike_sources, neurons, p.FromListConnector(input_connection_list))

                # If we have weights saved/recorded from a previous run of this network, load them into the structure
                # population.set(weights=weights_list) and population.setWeights(weight_list) are not supported in
                # SpiNNaker at the moment so we have to do this manually.
                if excitatory_weights and inhibitory_weights:
                    for index, ex_connection in enumerate(excitatory_connection_list):
                        ex_connection[2] = excitatory_weights[index]
                    for index, in_connection in enumerate(inhibitory_connection_list):
                        in_connection[2] = inhibitory_weights[index]

                # Setup the connectors
                excitatory_connector = p.FromListConnector(excitatory_connection_list)
                inhibitory_connector = p.FromListConnector(inhibitory_connection_list)

                # Connect the excitatory and inhibitory neuron populations
                connected_excitatory_neurons = p.Projection(neurons, neurons, excitatory_connector,
                                                            synapse_dynamics=p.SynapseDynamics(slow=stdp_model_ex),
                                                            target="excitatory")
                connected_inhibitory_neurons = p.Projection(neurons, neurons, inhibitory_connector,
                                                            synapse_dynamics=p.SynapseDynamics(slow=stdp_model_inh),
                                                            target="inhibitory")

                # Set up recording the spike trains of all the neurons
#.........这里部分代码省略.........
开发者ID:starlitnext,项目名称:NeuCubePyNN,代码行数:101,代码来源:NeuCubeReservoir.py

示例14: addressed

hostname="192.168.240.254" #ipaddress of packets to be sent to
strip_sdp=True



#p.activate_live_output_for(populations[0], portNo, hostname,  tag, strip_sdp, use_prefix, right_shift,
#				payload_as_time_stamps, use_payload_prefix, 
#				payload_prefix, payload_right_shift,
#				number_of_packets_sent_per_time_step)



p.activate_live_output_for(populations[0], portNo, hostname,tag=1,  strip_sdp=strip_sdp)



#populations[0].set_constraint( p.PartitionerMaximumSizeConstraint(5))
# 4 chips addressed (0,0) (0,1) (1,0) (1,1) so (2,2) out of range
#populations[0].set_mapping_constraint({'x':2, 'y':2, 'p':0})
#However (1,1) should work, but doesn't?
#populations[0].set_mapping_constraint({'x':1, 'y':1, 'p':0})

#same problem as above
#populations[0].set_constraint( p.PlacerChipAndCoreConstraint(2,2,0))

#populations[0].set_constraint( p.PlacerChipAndCoreConstraint(0,0,0))

p.run(400)

# p.end()
开发者ID:msil,项目名称:spinnaker-workshop,代码行数:30,代码来源:synfire_if_curr_exp3.py

示例15: open

                   'tau_syn_I' : 5.0,    #The inhibitory input current decay time-constant
                   'v_reset'   : -70.0,  #The voltage to set the neuron at immediately after a spike
                   'v_rest'    : -65.0,  #The ambient rest voltage of the neuron
                   'v_thresh'  : -50.0    #The threshold voltage at which the neuron will spike.
                   }


stim_pop1 = p.Population(n_neurons, p.SpikeSourcePoisson,{"rate": Hz,"start":0, "duration":pattern_length } ) #Stimuluspopultn
ip_pop = p.Population(n_neurons, p.IF_curr_exp, cell_params_lif, label="inputneurons")


project_stim_pop_ip_pop = p.Projection( stim_pop1,ip_pop, p.OneToOneConnector(weights=10, delays=1.0), target="excitatory")

ip_pop.record()
stim_pop1.record()
p.run(70)
spikes4 = ip_pop.getSpikes()
spikes5=stim_pop1.getSpikes()

with open('/home/ruthvik/Desktop/spikefile_'+str(Neurons)+'_'+str(pattern_length)+'ms'+'_'+str(Hz)+'Hz','w') as f:   ##make a pickle of spike data
    pickle.dump(spikes4,f)


spike_time4 = [i[1] for i in spikes4]
spike_id4 = [i[0] for i in spikes4]
pylab.plot(spike_time4, spike_id4, ".")
pylab.xlabel("Time (ms)_stim_population")
pylab.ylabel("Neuron ID")
pylab.axis([0,70,0,Neurons])
pylab.show()
开发者ID:ruthvik92,项目名称:spiNNaker-Codes.,代码行数:30,代码来源:poisson_pattern.py


注:本文中的pyNN.spiNNaker.run函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。