• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pyNN.run函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_script

    def test_script(self):
        """
        test that tests the printing of v from a pre determined recording
        :return:
        """
        p.setup(timestep=1.0, min_delay=1.0, max_delay=144.0)
        n_neurons = 128 * 128  # number of neurons in each population
        p.set_number_of_neurons_per_core("IF_cond_exp", 256)

        cell_params_lif = {'cm': 0.25,
                           'i_offset': 0.0,
                           'tau_m': 20.0,
                           'tau_refrac': 2.0,
                           'tau_syn_E': 5.0,
                           'tau_syn_I': 5.0,
                           'v_reset': -70.0,
                           'v_rest': -65.0,
                           'v_thresh': -50.0,
                           'e_rev_E': 0.,
                           'e_rev_I': -80.
                           }

        populations = list()
        projections = list()

        weight_to_spike = 0.035
        delay = 17

        spikes = read_spikefile('test.spikes', n_neurons)
        print spikes
        spike_array = {'spike_times': spikes}

        populations.append(p.Population(
            n_neurons, p.SpikeSourceArray, spike_array, label='inputSpikes_1'))
        populations.append(p.Population(
            n_neurons, p.IF_cond_exp, cell_params_lif, label='pop_1'))
        projections.append(p.Projection(
            populations[0], populations[1], p.OneToOneConnector(
                weights=weight_to_spike, delays=delay)))
        populations[1].record()

        p.run(1000)

        spikes = populations[1].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')
            pylab.title('spikes')
            pylab.show()
        else:
            print "No spikes received"

        p.end()
开发者ID:Paul92,项目名称:sPyNNaker,代码行数:57,代码来源:read_spike_file_1.0_time_step.py


示例2: test_recording_numerious_element_over_limit

    def test_recording_numerious_element_over_limit(self):
        p.setup(timestep=1.0, min_delay=1.0, max_delay=144.0)
        n_neurons = 2000  # number of neurons in each population
        p.set_number_of_neurons_per_core("IF_curr_exp", n_neurons / 2)

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

        populations = list()
        projections = list()

        boxed_array = numpy.zeros(shape=(0, 2))
        spike_array = list()
        for neuron_id in range(0, n_neurons):
            spike_array.append(list())
            for random_time in range(0, 200000):
                random_time2 = random.randint(0, 50000)
                boxed_array = numpy.append(
                    boxed_array, [[neuron_id, random_time2]], axis=0)
                spike_array[neuron_id].append(random_time)
        spike_array_params = {'spike_times': spike_array}
        populations.append(p.Population(n_neurons, p.IF_curr_exp,
                                        cell_params_lif,
                           label='pop_1'))
        populations.append(p.Population(n_neurons, p.SpikeSourceArray,
                                        spike_array_params,
                           label='inputSpikes_1'))

        projections.append(p.Projection(populations[1], populations[0],
                           p.OneToOneConnector()))

        populations[1].record()

        p.run(50000)

        spike_array_spikes = populations[1].getSpikes()
        boxed_array = boxed_array[numpy.lexsort((boxed_array[:, 1],
                                                 boxed_array[:, 0]))]
        numpy.testing.assert_array_equal(spike_array_spikes, boxed_array)
        p.end()
开发者ID:apdavison,项目名称:sPyNNaker,代码行数:48,代码来源:test_spike_source_array.py


示例3: test_get_weights

    def test_get_weights(self):
        # Population parameters
        cell_params = {
            'cm': 0.2,  # nF
            'i_offset': 0.2,
            'tau_m': 20.0,
            'tau_refrac': 5.0,
            'tau_syn_E': 5.0,
            'tau_syn_I': 10.0,
            'v_reset': -60.0,
            'v_rest': -60.0,
            'v_thresh': -50.0
        }

        # Reduce number of neurons to simulate on each core
        sim.set_number_of_neurons_per_core(sim.IF_curr_exp, 100)

        # Build inhibitory plasticity  model
        stdp_model = sim.STDPMechanism(
            timing_dependence=sim.SpikePairRule(
                tau_plus=20.0, tau_minus=12.7, nearest=True),
            weight_dependence=sim.AdditiveWeightDependence(
                w_min=0.0, w_max=1.0, A_plus=0.05),
            mad=True
        )

        # Build plastic network
        plastic_ex_pop, plastic_ie_projection =\
            self.build_network(sim.SynapseDynamics(slow=stdp_model), 
                               cell_params)

        # Run simulation
        sim.run(10000)

        # Get plastic spikes and save to disk
        plastic_spikes = plastic_ex_pop.getSpikes(compatible_output=True)
        #numpy.save("plastic_spikes.npy", plastic_spikes)

        plastic_weights = plastic_ie_projection.getWeights(format="array")
        #  mean_weight = numpy.average(plastic_weights)

        # End simulation on SpiNNaker
        sim.end()
开发者ID:Paul92,项目名称:sPyNNaker,代码行数:43,代码来源:stdp_to_read_get_weights_master_pop_binary.py


示例4: main

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

    # create a spike sources
    retinaLeft = createSpikeSource("RetL")
    retinaRight = createSpikeSource("RetR")
    
    # create network and attach the spike sources 
    network, (liveConnectionNetwork, liveConnectionRetinas) = createCooperativeNetwork(retinaLeft=retinaLeft, retinaRight=retinaRight)

    # non-blocking run for time in milliseconds
    print "Simulation started..."
    Frontend.run(simulationTime)                                          
    print "Simulation ended."
    
    # plot results  
    #
#     plotExperiment(retinaLeft, retinaRight, network)
    # finalise program and simulation
    Frontend.end()
开发者ID:AMFtech,项目名称:StereoMatching,代码行数:21,代码来源:CooperativeNetwork.py


示例5: test_recording_1_element

    def test_recording_1_element(self):
        p.setup(timestep=1.0, min_delay=1.0, max_delay=144.0)
        n_neurons = 200  # number of neurons in each population
        p.set_number_of_neurons_per_core("IF_curr_exp", n_neurons / 2)

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

        populations = list()
        projections = list()

        spike_array = {'spike_times': [[0]]}
        populations.append(p.Population(n_neurons, p.IF_curr_exp,
                                        cell_params_lif,
                           label='pop_1'))
        populations.append(p.Population(1, p.SpikeSourceArray, spike_array,
                           label='inputSpikes_1'))

        projections.append(p.Projection(populations[0], populations[0],
                           p.OneToOneConnector()))

        populations[1].record()

        p.run(5000)

        spike_array_spikes = populations[1].getSpikes()
        boxed_array = numpy.zeros(shape=(0, 2))
        boxed_array = numpy.append(boxed_array, [[0, 0]], axis=0)
        numpy.testing.assert_array_equal(spike_array_spikes, boxed_array)

        p.end()
开发者ID:apdavison,项目名称:sPyNNaker,代码行数:39,代码来源:test_spike_source_array.py


示例6: simulate

    def simulate(self, spinnaker, input_spike_times):

        # Cell parameters
        cell_params = {
            'tau_m': 20.0,
            'v_rest': -60.0,
            'v_reset': -60.0,
            'v_thresh': -40.0,
            'tau_syn_E': 2.0,
            'tau_syn_I': 2.0,
            'tau_refrac': 2.0,
            'cm': 0.25,
            'i_offset': 0.0,
        }

        rng = p.NumpyRNG(seed=28375)
        v_init = p.RandomDistribution('uniform', [-60, -40], rng)

        p.setup(timestep=1.0, min_delay=1.0, max_delay=10.0)

        pop = p.Population(1, p.IF_curr_exp, cell_params, label='population')
        pop.randomInit(v_init)
        pop.record()
        pop.record_v()

        noise = p.Population(1, p.SpikeSourceArray,
                             {"spike_times": input_spike_times})

        p.Projection(noise, pop, p.OneToOneConnector(weights=0.4, delays=1),
                     target='excitatory')

        # Simulate
        p.run(self.simtime)

        pop_voltages = pop.get_v(compatible_output=True)
        pop_spikes = pop.getSpikes(compatible_output=True)

        p.end()
        return pop_voltages, pop_spikes
开发者ID:Paul92,项目名称:sPyNNaker,代码行数:39,代码来源:test_a_single_if_cur_exp_neuron.py


示例7: test_recording_poisson_spikes_rate_0

    def test_recording_poisson_spikes_rate_0(self):

        p.setup(timestep=1.0, min_delay=1.0, max_delay=144.0)
        n_neurons = 256  # number of neurons in each population
        p.set_number_of_neurons_per_core("IF_curr_exp", n_neurons / 2)

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

        populations = list()
        projections = list()

        populations.append(p.Population(n_neurons, p.IF_curr_exp,
                                        cell_params_lif,
                           label='pop_1'))
        populations.append(p.Population(n_neurons, p.SpikeSourcePoisson,
                                        {'rate': 0},
                           label='inputSpikes_1'))

        projections.append(p.Projection(populations[1], populations[0],
                           p.OneToOneConnector()))

        populations[1].record()

        p.run(5000)

        spikes = populations[1].getSpikes()
        print spikes

        p.end()
开发者ID:SpikeFrame,项目名称:sPyNNaker,代码行数:38,代码来源:test_poisson_spike_source.py


示例8: SpynnakerLiveSpikesConnection

    for neuron_id in neuron_ids:
        print "Received spike at time", time, "from", label, "-", neuron_id
# Set up the live connection for sending spikes
live_spikes_connection = SpynnakerLiveSpikesConnection(
    receive_labels=None, local_port=19999, send_labels=["spike_injector_forward"])
# Set up callbacks to occur at the start of simulation
live_spikes_connection.add_start_callback("spike_injector_forward", send_input_forward)
# if not using the c visualiser, then a new spynnaker live spikes connection
# is created to define that there are python code which receives the
# outputted spikes.
live_spikes_connection = SpynnakerLiveSpikesConnection(
    receive_labels=["pop_forward"], local_port=19996, send_labels=None)
# Set up callbacks to occur when spikes are received
live_spikes_connection.add_receive_callback("pop_forward", receive_spikes)
# Run the simulation on spiNNaker
Frontend.run(run_time)
# Retrieve spikes from the synfire chain population
spikes_forward = pop_forward.getSpikes()
# If there are spikes, plot using matplotlib
if len(spikes_forward) != 0:
    pylab.figure()
    if len(spikes_forward) != 0:
        pylab.plot([i[1] for i in spikes_forward],
                   [i[0] for i in spikes_forward], "b.")
    pylab.ylabel('neuron id')
    pylab.xlabel('Time/ms')
    pylab.title('spikes')
    pylab.show()
else:
    print "No spikes received"
# Clear data structures on spiNNaker to leave the machine in a clean state for
开发者ID:SpiNNakerManchester,项目名称:SpiNNakerManchester.github.io,代码行数:31,代码来源:simple_IO_vis_task1.3.py


示例9:

import spynnaker.pyNN as sim

sim.setup(timestep=1.0, min_delay=1.0, max_delay=1.0)

simtime = 1000

pg_pop1 = sim.Population(2, sim.SpikeSourcePoisson,
                         {'rate': 10.0, 'start':0,
                          'duration':simtime}, label="pg_pop1")
pg_pop2 = sim.Population(2, sim.SpikeSourcePoisson,
                         {'rate': 10.0, 'start':0,
                          'duration':simtime}, label="pg_pop2")

pg_pop1.record()
pg_pop2.record()

sim.run(simtime)

spikes1 = pg_pop1.getSpikes(compatible_output=True)
spikes2 = pg_pop2.getSpikes(compatible_output=True)

print spikes1
print spikes2

sim.end()
开发者ID:Paul92,项目名称:sPyNNaker,代码行数:25,代码来源:test_poisson.py


示例10:

spikeArray = {'spike_times': [[1050, 1060, 1500,1700, 1900, 2200]]}
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)
p.run(runtime)
p.run(runtime)

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')
    pylab.title('spikes')
开发者ID:SpikeFrame,项目名称:sPyNNaker,代码行数:31,代码来源:synfire_3_run_no_spikes_in_first_multiple_second_exit_no_extraction_if_curr_exp.py


示例11:

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_1_run_reset_1_run__smaller_runtime_no_extraction_if_curr_exp.py


示例12:

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

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:ruthvik92,项目名称:PyNNExamples,代码行数:31,代码来源:synfire_if_curr_exp.py


示例13: list

populations[0].record()
ExternalDevices.activate_live_output_for(populations[0])

projections.append(
    FrontEnd.Projection(populations[1], populations[0], FrontEnd.OneToOneConnector(weights=weight_to_spike))
)

loopConnections = list()
for i in range(0, nNeurons - 1):
    singleConnection = (i, ((i + 1) % nNeurons), weight_to_spike, 3)
    loopConnections.append(singleConnection)

projections.append(FrontEnd.Projection(populations[0], populations[0], FrontEnd.FromListConnector(loopConnections)))


FrontEnd.run(run_time)

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.ylabel("neuron id")
    pylab.xlabel("Time/ms")
    pylab.title("spikes")
    pylab.show()
else:
    print "No spikes received"

FrontEnd.end()
开发者ID:mdjurfeldt,项目名称:sPyNNakerExternalDevicesPlugin,代码行数:31,代码来源:spike_injection.py


示例14: test_get_voltage

    def test_get_voltage(self):
        """
        test that tests the getting of v from a pre determined recording
        :return:
        """
        p.setup(timestep=0.1, min_delay=1.0, max_delay=14.40)
        n_neurons = 200  # number of neurons in each population
        runtime = 500
        p.set_number_of_neurons_per_core("IF_curr_exp", n_neurons / 2)

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

        populations = list()
        projections = list()

        weight_to_spike = 2.0
        delay = 1.7

        loop_connections = list()
        for i in range(0, n_neurons):
            single_connection = (i, ((i + 1) % n_neurons), weight_to_spike,
                                 delay)
            loop_connections.append(single_connection)

        injection_connection = [(0, 0, weight_to_spike, 1)]
        spike_array = {'spike_times': [[0]]}
        populations.append(p.Population(n_neurons, p.IF_curr_exp, cell_params_lif,
                           label='pop_1'))
        populations.append(p.Population(1, p.SpikeSourceArray, spike_array,
                           label='inputSpikes_1'))

        projections.append(p.Projection(populations[0], populations[0],
                           p.FromListConnector(loop_connections)))
        projections.append(p.Projection(populations[1], populations[0],
                           p.FromListConnector(injection_connection)))

        populations[0].record_v()
        populations[0].record_gsyn()
        populations[0].record()

        p.run(runtime)

        v = populations[0].get_v(compatible_output=True)

        current_file_path = os.path.dirname(os.path.abspath(__file__))
        current_file_path = os.path.join(current_file_path, "v.data")
        pre_recorded_data = p.utility_calls.read_in_data_from_file(
            current_file_path, 0, n_neurons, 0, runtime)

        p.end()

        for spike_element, read_element in zip(v, pre_recorded_data):
            self.assertEqual(round(spike_element[0], 1),
                             round(read_element[0], 1))
            self.assertEqual(round(spike_element[1], 1),
                             round(read_element[1], 1))
            self.assertEqual(round(spike_element[2], 1),
                             round(read_element[2], 1))
开发者ID:Paul92,项目名称:sPyNNaker,代码行数:67,代码来源:synfire_0.1_timestep_test_get_v.py


示例15: build_network

    sim.Projection(ex_pop, ex_pop, sim.FixedProbabilityConnector(0.02, weights=0.03), target='excitatory')

    # Make inhibitory->inhibitory projections
    sim.Projection(in_pop, in_pop, sim.FixedProbabilityConnector(0.02, weights=-0.3), target='inhibitory')
    
    # Make inhibitory->excitatory projections
    ie_projection = sim.Projection(in_pop, ex_pop, sim.FixedProbabilityConnector(0.02, weights=0), target='inhibitory', synapse_dynamics = dynamics)

    return ex_pop, ie_projection


# Build static network
static_ex_pop,_ = build_network(None)

# Run for 1s
sim.run(1000)

# Get static spikes and save to disk
static_spikes = static_ex_pop.getSpikes(compatible_output=True)

# Build inhibitory plasticity  model
stdp_model = sim.STDPMechanism(
    timing_dependence = q.Vogels2011Rule(alpha=0.12,tau=20.0),
    weight_dependence = sim.AdditiveWeightDependence(w_min=0.0, w_max=1.0, A_plus=0.05),
    mad=True
)

# Build plastic network
plastic_ex_pop, plastic_ie_projection = build_network(sim.SynapseDynamics(slow = stdp_model))

# Run simulation
开发者ID:ericnichols,项目名称:sPyNNakerExtraModelsPlugin,代码行数:31,代码来源:vogels_2011.py


示例16: __init__

    def __init__(self):

        # initial call to set up the front end (pynn requirement)
        Frontend.setup(timestep=1.0, min_delay=1.0, max_delay=144.0)

        use_c_visualiser = True
        use_spike_injector = True

        # neurons per population and the length of runtime in ms for the
        # simulation, as well as the expected weight each spike will contain
        self.n_neurons = 100

        # set up gui
        p = None
        if use_spike_injector:
            from multiprocessing import Process
            from multiprocessing import Event
            ready = Event()
            p = Process(target=GUI, args=[self.n_neurons, ready])
            p.start()
            ready.wait()

        # different runtimes for demostration purposes
        run_time = None
        if not use_c_visualiser and not use_spike_injector:
            run_time = 1000
        elif use_c_visualiser and not use_spike_injector:
            run_time = 10000
        elif use_c_visualiser and use_spike_injector:
            run_time = 100000
        elif not use_c_visualiser and use_spike_injector:
            run_time = 10000

        weight_to_spike = 2.0

        # neural parameters of the IF_curr model used to respond to injected
        # spikes.
        # (cell params for a synfire chain)
        cell_params_lif = {'cm': 0.25,
                           'i_offset': 0.0,
                           'tau_m': 20.0,
                           'tau_refrac': 2.0,
                           'tau_syn_E': 5.0,
                           'tau_syn_I': 5.0,
                           'v_reset': -70.0,
                           'v_rest': -65.0,
                           'v_thresh': -50.0
                           }

        ##################################
        # Parameters for the injector population.  This is the minimal set of
        # parameters required, which is for a set of spikes where the key is
        # not important.  Note that a virtual key *will* be assigned to the
        # population, and that spikes sent which do not match this virtual key
        # will be dropped; however, if spikes are sent using 16-bit keys, they
        # will automatically be made to match the virtual key.  The virtual
        # key assigned can be obtained from the database.
        ##################################
        cell_params_spike_injector = {

            # The port on which the spiNNaker machine should listen for
            # packets. Packets to be injected should be sent to this port on
            # the spiNNaker machine
            'port': 12345
        }

        ##################################
        # Parameters for the injector population.  Note that each injector
        # needs to be given a different port.  The virtual key is assigned
        # here, rather than being allocated later.  As with the above, spikes
        # injected need to match this key, and this will be done automatically
        # with 16-bit keys.
        ##################################
        cell_params_spike_injector_with_key = {

            # The port on which the spiNNaker machine should listen for
            # packets. Packets to be injected should be sent to this port on
            # the spiNNaker machine
            'port': 12346,

            # This is the base key to be used for the injection, which is used
            # to allow the keys to be routed around the spiNNaker machine.
            # This assignment means that 32-bit keys must have the high-order
            # 16-bit set to 0x7; This will automatically be prepended to
            # 16-bit keys.
            'virtual_key': 0x70000
        }

        # create synfire populations (if cur exp)
        pop_forward = Frontend.Population(
            self.n_neurons, Frontend.IF_curr_exp,
            cell_params_lif, label='pop_forward')
        pop_backward = Frontend.Population(
            self.n_neurons, Frontend.IF_curr_exp,
            cell_params_lif, label='pop_backward')

        # Create injection populations
        injector_forward = None
        injector_backward = None
        if use_spike_injector:
#.........这里部分代码省略.........
开发者ID:ruthvik92,项目名称:PyNNExamples,代码行数:101,代码来源:spike_io_interactive_demo_with_c_vis.py


示例17: print

        # Plastic Connection between pre_pop and post_pop
        # Sjostrom visual cortex min-triplet params
        stdp_model = sim.STDPMechanism(
            timing_dependence = sim.PfisterSpikeTripletRule(tau_plus = 16.8, tau_minus = 33.7, tau_x = 101, tau_y = 114),
            weight_dependence = sim.AdditiveWeightDependence(w_min = 0.0, w_max = 1.0, A_plus = param_scale * 0.0, A_minus = param_scale * 7.1e-3, A3_plus = param_scale * 6.5e-3, A3_minus = param_scale * 0.0)
        )

        projections[-1].append(sim.Projection(pre_pop, post_pop, sim.OneToOneConnector(weights = start_w),
            synapse_dynamics = sim.SynapseDynamics(slow = stdp_model)
        ))

print("Simulating for %us" % (sim_time / 1000))

# Run simulation
sim.run(sim_time)

# Read weights from each parameter value being tested
weights = []
for projection_delta_t in projections:
    weights.append([p.getWeights()[0] for p in projection_delta_t])

# End simulation on SpiNNaker
sim.end(stop_on_board=True)

#-------------------------------------------------------------------
# Plotting
#-------------------------------------------------------------------
# Sjostrom et al. (2001) experimental data
data_w = [
    [ -0.29, -0.41, -0.34, 0.56, 0.75 ],
开发者ID:Paul92,项目名称:sPyNNaker,代码行数:30,代码来源:stdp_triplet.py


示例18: range

spike_sourceE = sim.Population(1, sim.SpikeSourceArray, {'spike_times': [float(i) for i in range(5,105,10)]})
spike_sourceI = sim.Population(1, sim.SpikeSourceArray, {'spike_times': [float(i) for i in range(155,255,10)]})

sim.Projection(spike_sourceE, exp_cell, sim.OneToOneConnector(weights=0.15, delays=2.0), target='excitatory')
sim.Projection(spike_sourceI, exp_cell, sim.OneToOneConnector(weights=-0.15, delays=4.0), target='inhibitory')
sim.Projection(spike_sourceE, stoc_cell, sim.OneToOneConnector(weights=0.15, delays=2.0), target='excitatory')
sim.Projection(spike_sourceI, stoc_cell, sim.OneToOneConnector(weights=-0.15, delays=4.0), target='inhibitory')

stoc_cell.record_gsyn()
exp_cell.record_gsyn()
stoc_cell.record_v()
exp_cell.record_v()
stoc_cell.record()
exp_cell.record()

sim.run(200.0)

v_delta = stoc_cell.get_v()
i_delta = stoc_cell.get_gsyn()
v_exp = exp_cell.get_v()
i_exp = exp_cell.get_gsyn()

# Plot
fig, axis = pylab.subplots(2)

axis[0].plot(v_delta[:,1], v_delta[:,2], label="Stochastic")
axis[0].plot(v_exp[:,1], v_exp[:,2], label="Static")
axis[0].set_title("Voltage")
axis[0].legend()

axis[1].plot(i_delta[:,1], i_delta[:,2], label="Stochastic")
开发者ID:ericnichols,项目名称:sPyNNakerExtraModelsPlugin,代码行数:31,代码来源:IF_cond_exp_stoc.py


示例19:

# Record excitatory spikes
ex_pop.record()

# Make excitatory->inhibitory projections
sim.Projection(ex_pop, in_pop, sim.FixedProbabilityConnector(0.02, weights=0.03), target='excitatory')
sim.Projection(ex_pop, ex_pop, sim.FixedProbabilityConnector(0.02, weights=0.03), target='excitatory')

# Make inhibitory->inhibitory projections
sim.Projection(in_pop, in_pop, sim.FixedProbabilityConnector(0.02, weights=-0.3), target='inhibitory')

# Build inhibitory plasticity  model
stdp_model = sim.STDPMechanism(
    timing_dependence = extra_sim.Vogels2011Rule(alpha=0.12,tau=20.0),
    weight_dependence = sim.AdditiveWeightDependence(w_min=0.0, w_max=1.0, A_plus=0.0005),
    mad=True
)

# Make inhibitory->excitatory projections
sim.Projection(in_pop, ex_pop, sim.FixedProbabilityConnector(0.02, weights=0), target='inhibitory', 
               synapse_dynamics=sim.SynapseDynamics(slow=stdp_model))

# Activate live output for excitatory spikes
ext.activate_live_output_for(ex_pop)
ext.activate_live_output_for(in_pop)

# Run simulation
sim.run(5000)

# End simulation on SpiNNaker
sim.end()
开发者ID:ericnichols,项目名称:sPyNNakerExtraModelsPlugin,代码行数:30,代码来源:vogels_2011_live.py


示例20: test_print_spikes

    def test_print_spikes(self):
        machine_time_step = 0.1

        p.setup(timestep=machine_time_step, min_delay=1.0, max_delay=14.40)
        n_neurons = 20  # number of neurons in each population
        p.set_number_of_neurons_per_core("IF_curr_exp", n_neurons / 2)


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

        populations = list()
        projections = list()

        weight_to_spike = 2.0
        delay = 1.7

        loop_connections = list()
        for i in range(0, n_neurons):
            single_connection = (i, ((i + 1) % n_neurons), weight_to_spike,
                                 delay)
            loop_connections.append(single_connection)

        injection_connection = [(0, 0, weight_to_spike, 1)]
        spike_array = {'spike_times': [[0]]}
        populations.append(p.Population(n_neurons, p.IF_curr_exp,
                                        cell_params_lif,
                           label='pop_1'))
        populations.append(p.Population(1, p.SpikeSourceArray, spike_array,
                           label='inputSpikes_1'))

        projections.append(p.Projection(populations[0], populations[0],
                           p.FromListConnector(loop_connections)))
        projections.append(p.Projection(populations[1], populations[0],
                           p.FromListConnector(injection_connection)))

        populations[0].record_v()
        populations[0].record_gsyn()
        populations[0].record()

        p.run(500)

        spikes = populations[0].getSpikes(compatible_output=True)

        current_file_path = os.path.dirname(os.path.abspath(__file__))
        current_file_path = os.path.join(current_file_path, "spikes.data")
        spike_file = populations[0].printSpikes(current_file_path)

        spike_reader = p.utility_calls.read_spikes_from_file(
            current_file_path, min_atom=0, max_atom=n_neurons,
            min_time=0, max_time=500)
        read_in_spikes = spike_reader.spike_times
        p.end()
        os.remove(current_file_path)

        for spike_element, read_element in zip(spikes, read_in_spikes):
            self.assertEqual(round(spike_element[0], 1),
                             round(read_element[0], 1))
            self.assertEqual(round(spike_element[1], 1),
                             round(read_element[1], 1))
开发者ID:Paul92,项目名称:sPyNNaker,代码行数:68,代码来源:synfire_0.1_timestep_test_print_spikes.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pyNN.set_number_of_neurons_per_core函数代码示例发布时间:2022-05-27
下一篇:
Python pyNN.end函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap