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

Python pyNN.setup函数代码示例

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

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



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

示例1: test_invalid_max_delay

 def test_invalid_max_delay(self):
     """
     tests that with invalid user input the max delay raises correctly
     :return:
     """
     with self.assertRaises(ConfigurationException):
         p.setup(1, max_delay=100000)
开发者ID:SpikeFrame,项目名称:sPyNNaker,代码行数:7,代码来源:simulation_tests.py


示例2: build_network

    def build_network(self, dynamics, cell_params):
        """
        Function to build the basic network - dynamics should be a PyNN
         synapse dynamics object
:param dynamics: 
:return:
        """
        # SpiNNaker setup
        model = sim.IF_curr_exp
        sim.setup(timestep=0.1, min_delay=1.0, max_delay=10.0)

        # Create excitatory and inhibitory populations of neurons
        ex_pop = sim.Population(NUM_EXCITATORY, model, cell_params)
        in_pop = sim.Population(NUM_EXCITATORY / 4, model, cell_params)

        # 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')

        # 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
开发者ID:Paul92,项目名称:sPyNNaker,代码行数:34,代码来源:stdp_to_read_get_weights_master_pop_binary.py


示例3: test_invalid_min_delay_1_millisecond_timestep

 def test_invalid_min_delay_1_millisecond_timestep(self):
     """
      tests if with invalid user min, the min raises exefpetiosn
     :return:
     """
     with self.assertRaises(ConfigurationException):
         p.setup(1, min_delay=0.1)
开发者ID:SpikeFrame,项目名称:sPyNNaker,代码行数:7,代码来源:simulation_tests.py


示例4: test_valid_max_delay_0_1_millisecond_timestep

 def test_valid_max_delay_0_1_millisecond_timestep(self):
     """
     tests if with valid user min, the min is set correctly
     :return:
     """
     p.setup(0.1, max_delay=0.4)
     max_delay = p.get_max_delay()
     self.assertEqual(max_delay, 0.4)
开发者ID:SpikeFrame,项目名称:sPyNNaker,代码行数:8,代码来源:simulation_tests.py


示例5: test_max_delay_no_user_input_1_millisecond_timestep

 def test_max_delay_no_user_input_1_millisecond_timestep(self):
     """
     Tests that with no user input, the max delay is correct
     :return:
     """
     p.setup(1)
     max_delay = p.get_max_delay()
     self.assertEqual(max_delay, 144)
开发者ID:SpikeFrame,项目名称:sPyNNaker,代码行数:8,代码来源:simulation_tests.py


示例6: test_get_min_delay_0_1_milisecond_timestep

 def test_get_min_delay_0_1_milisecond_timestep(self):
     """
     tests if with no user min, the min is set to 1 timestep in millisencsd
     :return:
     """
     p.setup(0.1)
     min_delay = p.get_min_delay()
     self.assertEqual(min_delay, 0.1)
开发者ID:SpikeFrame,项目名称:sPyNNaker,代码行数:8,代码来源:simulation_tests.py


示例7: 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


示例8: 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


示例9: test_initial_setup

 def test_initial_setup(self):
     import spynnaker.pyNN as pynn
     self.assertEqual(pynn.setup(timestep=1, min_delay=1, max_delay=15.0),
                      None)
     self.assertEqual(conf.config.getint("Machine", "machineTimeStep"),
                      1 * 1000)
     self.assertEqual(pynn.get_min_delay(), 1)
     self.assertEqual(pynn.get_max_delay(), 15.0)
开发者ID:apdavison,项目名称:sPyNNaker,代码行数:8,代码来源:test_pynn.py


示例10: 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


示例11: 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


示例12: build_network

def build_network(dynamics):
    # SpiNNaker setup
    sim.setup(timestep=1.0, min_delay=1.0, max_delay=10.0)

    # Create excitatory and inhibitory populations of neurons
    ex_pop = sim.Population(NUM_EXCITATORY, model, cell_params)
    in_pop = sim.Population(NUM_EXCITATORY / 4, model, cell_params)
    
    # 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')
    
    # 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
开发者ID:ericnichols,项目名称:sPyNNakerExtraModelsPlugin,代码行数:22,代码来源:vogels_2011.py


示例13: 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


示例14: 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


示例15: list

import spynnaker.pyNN as FrontEnd
import spynnaker_external_devices_plugin.pyNN as ExternalDevices

import pylab

FrontEnd.setup(timestep=1.0)

nNeurons = 100
run_time = 10000

cell_params_lif = {
    "cm": 0.25,  # nF
    "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,
}

cell_params_spike_injector_new = {"virtual_key": 0x70800, "port": 12345}

populations = list()
projections = list()

weight_to_spike = 2.0

populations.append(FrontEnd.Population(nNeurons, FrontEnd.IF_curr_exp, cell_params_lif, label="pop_1"))
populations.append(
开发者ID:mdjurfeldt,项目名称:sPyNNakerExternalDevicesPlugin,代码行数:31,代码来源:spike_injection.py


示例16: 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


示例17: TestIFCurrDualExpModel

import unittest
from spynnaker.pyNN.models.neuron.builds.if_curr_dual_exp import IFCurrDualExp
import spynnaker.pyNN as pyNN

if not pyNN:
    pyNN.setup(1, 1, 15)


class TestIFCurrDualExpModel(unittest.TestCase):
    def test_new_if_curr_dual_exp_model(self):
        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_E2': 5.0,
                           'tau_syn_I': 5.0,
                           'v_reset': -70.0,
                           'v_rest': -65.0,
                           'v_thresh': -50.0}
        n_neurons = 10
        if_curr_dual_exp = IFCurrDualExp(
            n_neurons, 1000, 1.0, **cell_params_lif)
        self.assertEqual(if_curr_dual_exp.model_name, "IF_curr_dual_exp")
        self.assertEqual(len(if_curr_dual_exp.get_parameters()), 10)
        self.assertEqual(if_curr_dual_exp._v_thresh,
                         cell_params_lif['v_thresh'])
        self.assertEqual(if_curr_dual_exp._v_reset, cell_params_lif['v_reset'])
        self.assertEqual(if_curr_dual_exp._v_rest, cell_params_lif['v_rest'])
        self.assertEqual(if_curr_dual_exp._tau_m, cell_params_lif['tau_m'])
        self.assertEqual(if_curr_dual_exp._tau_refrac,
开发者ID:SpikeFrame,项目名称:sPyNNaker,代码行数:31,代码来源:test_if_curr_dual_exp_model.py


示例18: end

# imports of both spynnaker and external device plugin.
import spynnaker.pyNN as Frontend
import spynnaker_external_devices_plugin.pyNN as ExternalDevices
from spynnaker_external_devices_plugin.pyNN.connections\
    .spynnaker_live_spikes_connection import SpynnakerLiveSpikesConnection
# plotter in python
import pylab
# initial call to set up the front end (pynn requirement)
Frontend.setup(timestep=1.0, min_delay=1.0, max_delay=144.0)
# neurons per population and the length of runtime in ms for the simulation,
# as well as the expected weight each spike will contain
n_neurons = 100
run_time = 8000
weight_to_spike = 2.0
# neural parameters of the ifcur 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}
# create synfire populations (if cur exp)
pop_forward = Frontend.Population(n_neurons, Frontend.IF_curr_exp,
                                  cell_params_lif, label='pop_forward')
# Create injection populations
injector_forward = Frontend.Population(
    n_neurons, ExternalDevices.SpikeInjector,
    {'port':12365}, label='spike_injector_forward')
# Create a connection from the injector into the populations
Frontend.Projection(injector_forward, pop_forward,
                    Frontend.OneToOneConnector(weights=weight_to_spike))
# Synfire chain connections where each neuron is connected to its next neuron
# NOTE: there is no recurrent connection so that each chain stops once it
开发者ID:SpiNNakerManchester,项目名称:SpiNNakerManchester.github.io,代码行数:31,代码来源:simple_IO_vis_task1.3.py


示例19: main

def main():
    minutes = 0
    seconds = 30
    milliseconds = 0
    run_time = minutes*60*1000 + seconds*1000 + milliseconds

    weight_to_spike = 4.

    model = sim.IF_curr_exp
    cell_params = {'cm'        : 0.25, # nF
                    'i_offset'  : 0.0,
                    'tau_m'     : 10.0,
                    'tau_refrac': 2.0,
                    'tau_syn_E' : 2.5,
                    'tau_syn_I' : 2.5,
                    'v_reset'   : -70.0,
                    'v_rest'    : -65.0,
                    'v_thresh'  : -55.4
                    }
    # Available resolutions
    # 16, 32, 64, 128
    mode = ExternalDvsEmulatorDevice.MODE_64
    cam_res = int(mode)
    cam_fps = 90
    frames_per_saccade = cam_fps/3 - 1
    polarity = ExternalDvsEmulatorDevice.MERGED_POLARITY
    output_type = ExternalDvsEmulatorDevice.OUTPUT_TIME
    history_weight = 1.0
    behaviour = VirtualCam.BEHAVE_ATTENTION
    vcam = VirtualCam("./mnist", behaviour=behaviour, fps=cam_fps, 
                      resolution=cam_res, frames_per_saccade=frames_per_saccade)
                      
    cam_params = {'mode': mode,
                  'polarity': polarity,
                  'threshold': 12,
                  'adaptive_threshold': False,
                  'fps': cam_fps,
                  'inhibition': False,
                  'output_type': output_type,
                  'save_spikes': "./spikes_from_cam.pickle",
                  'history_weight': history_weight,
                  #'device_id': 0, # for an OpenCV webcam device
                  #'device_id': 'path/to/video/file', # to encode pre-recorded video
                  'device_id': vcam,
                 }
    if polarity == ExternalDvsEmulatorDevice.MERGED_POLARITY:
        num_neurons = 2*(cam_res**2)
    else:
        num_neurons = cam_res**2
      
    sim.setup(timestep=1.0, min_delay=1.0, max_delay=10.0)

    target = sim.Population(num_neurons, model, cell_params)

    stimulation = sim.Population(num_neurons, DvsEmulatorDevice, cam_params,
                                 label="Webcam population")

    connector = sim.OneToOneConnector(weights=weight_to_spike)

    projection = sim.Projection(stimulation, target, connector)

    target.record()
        
    sim.run(run_time)

    
    spikes = target.getSpikes(compatible_output=True)

    sim.end()
    #stimulation._vertex.stop()
    
    
    print ("Raster plot of the spikes that Spinnaker echoed back")
    fig = pylab.figure()
    
    spike_times = [spike_time for (neuron_id, spike_time) in spikes]
    spike_ids   = [neuron_id  for (neuron_id, spike_time) in spikes]
    
    pylab.plot(spike_times, spike_ids, ".", markerfacecolor="None",
               markeredgecolor="Blue", markersize=3)
    
    pylab.show()
开发者ID:chanokin,项目名称:pyDVS,代码行数:82,代码来源:spynnaker_test.py


示例20: test_get_spikes

    def test_get_spikes(self):
        """
        test for get spikes
        :return:
        """
        p.setup(timestep=1, min_delay=1.0, max_delay=14.40)
        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()

        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)
        pre_recorded_spikes = [
            [0, 3.5], [1, 6.7], [2, 9.9], [3, 13.1], [4, 16.3],
            [5, 19.5], [6, 22.7], [7, 25.9], [8, 29.1],
            [9, 32.3], [10, 35.5], [11, 38.7], [12, 41.9],
            [13, 45.1], [14, 48.3], [15, 51.5], [16, 54.7],
            [17, 57.9], [18, 61.1], [19, 64.3], [20, 67.5],
            [21, 70.7], [22, 73.9], [23, 77.1], [24, 80.3],
            [25, 83.5], [26, 86.7], [27, 89.9], [28, 93.1],
            [29, 96.3], [30, 99.5], [31, 102.7], [32, 105.9],
            [33, 109.1], [34, 112.3], [35, 115.5], [36, 118.7],
            [37, 121.9], [38, 125.1], [39, 128.3], [40, 131.5],
            [41, 134.7], [42, 137.9], [43, 141.1], [44, 144.3],
            [45, 147.5], [46, 150.7], [47, 153.9], [48, 157.1],
            [49, 160.3], [50, 163.5], [51, 166.7], [52, 169.9],
            [53, 173.1], [54, 176.3], [55, 179.5], [56, 182.7],
            [57, 185.9], [58, 189.1], [59, 192.3], [60, 195.5]]

        p.end()

        for spike_element, read_element in zip(spikes, pre_recorded_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,代码行数:74,代码来源:synfire_1.0_timestep_test_get_spikes.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python sql.doquery函数代码示例发布时间:2022-05-27
下一篇:
Python pyNN.set_number_of_neurons_per_core函数代码示例发布时间: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