예제 #1
0
def do_run(nNeurons):
    p.setup(timestep=1.0, min_delay=1.0, max_delay=144.0)
    max_delay = 50
    p.set_number_of_neurons_per_core("IF_curr_exp", nNeurons / 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 = numpy.random.RandomState()
    delays = list()

    connections = 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)
        connections.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(connections)))
    projections.append(
        p.Projection(populations[1], populations[0],
                     p.FromListConnector(injectionConnection)))

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

    run_time = (max_delay * nNeurons)
    print "Running for {} ms".format(run_time)
    p.run(run_time)

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

    p.end()

    return (v, gsyn, spikes)
def do_run():
    p.setup(timestep=1.0, min_delay=1.0, max_delay=1.0)

    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.}

    # setup test population
    if_pop = p.Population(1, p.IF_cond_exp, cell_params)
    # setup spike sources
    exc_pop = p.Population(1, p.SpikeSourceArray,
                           {'spike_times': [20., 40., 60.]})
    inh_pop = p.Population(1, p.SpikeSourceArray,
                           {'spike_times': [120., 140., 160.]})
    # setup excitatory and inhibitory connections
    listcon = p.FromListConnector([(0, 0, 0.01, 1.0)])
    p.Projection(exc_pop, if_pop, listcon, target='excitatory')
    p.Projection(inh_pop, if_pop, listcon, target='inhibitory')
    # setup recorder
    if_pop.record_v()
    p.run(200.)
    # read out voltage and plot
    V = if_pop.get_v()
    p.end()

    return V
예제 #3
0
 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)
예제 #4
0
def do_run(nNeurons):

    p.setup(timestep=1.0, min_delay=1.0, max_delay=32.0)
    p.set_number_of_neurons_per_core("IF_curr_exp", 250)

    cell_params_lif = {
        'cm': 0.25,
        'i_offset': 0.0,
        'tau_m': 20.0,
        'tau_refrac': 5.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 = 1.5
    delay = 1

    connections = list()
    for i in range(0, nNeurons):
        singleConnection = (i, ((i + 1) % nNeurons), weight_to_spike, delay)
        connections.append(singleConnection)

    injectionConnection = [(0, 0, weight_to_spike, delay)]

    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(connections)))
    projections.append(
        p.Projection(populations[1], populations[0],
                     p.FromListConnector(injectionConnection)))

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

    p.run(1000)
    ''''
    weights = projections[0].getWeights()
    delays = projections[0].getDelays()
    '''

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

    p.end()

    return (v, gsyn, spikes)
예제 #5
0
 def test_invalid_min_delay_1_millisecond_timestep(self):
     """
      tests if with invalid user min, the min raises exceptions
     :return:
     """
     with self.assertRaises(ConfigurationException):
         p.setup(1, min_delay=0.1)
    def test_multi_board_spike_output(self):
        TestMultiBoardSpikeOutput.counts = dict()
        p.setup(1.0, n_chips_required=((48 * 2) + 1))
        machine = p.get_machine()

        labels = list()
        for chip in machine.ethernet_connected_chips:
            print "Adding population on {}, {}".format(chip.x, chip.y)
            label = "{}, {}".format(chip.x, chip.y)
            labels.append(label)
            pop = p.Population(
                10, p.SpikeSourceArray,
                {"spike_times": [i for i in range(100)]},
                label=label)
            pop.add_placement_constraint(chip.x, chip.y)
            p.external_devices.activate_live_output_for(pop)
            TestMultiBoardSpikeOutput.counts[label] = 0

        live_output = p.external_devices.SpynnakerLiveSpikesConnection(
            receive_labels=labels)
        for label in labels:
            live_output.add_receive_callback(
                label, TestMultiBoardSpikeOutput.spike_receiver)

        p.run(1000)
        p.end()

        for label in labels:
            print "Received {} of 1000 spikes from {}".format(
                TestMultiBoardSpikeOutput.counts[label], label)
            self.assertEqual(TestMultiBoardSpikeOutput.counts[label], 1000)
예제 #7
0
def do_run(nNeurons):

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

    cell_params_lif_in = {
        'tau_m': 333.33,
        'cm': 208.33,
        'v_init': 0.0,
        'v_rest': 0.1,
        'v_reset': 0.0,
        'v_thresh': 1.0,
        'tau_syn_E': 1,
        'tau_syn_I': 2,
        'tau_refrac': 2.5,
        'i_offset': 3.0
    }

    pop1 = p.Population(nNeurons,
                        p.IF_curr_exp,
                        cell_params_lif_in,
                        label='pop_0')

    pop1.record_v()
    pop1.record_gsyn()
    pop1.record()

    p.run(3000)

    v = pop1.get_v(compatible_output=True)
    gsyn = pop1.get_gsyn(compatible_output=True)
    spikes = pop1.getSpikes(compatible_output=True)

    p.end()

    return (v, gsyn, spikes)
예제 #8
0
def do_run():
    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)

    sim.end()

    return (spikes1, spikes2)
예제 #9
0
 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)
예제 #10
0
 def test_get_min_delay_0_1_milisecond_timestep(self):
     """
     tests if with no user min, the min is set to 1 timestep in milliseconds
     :return:
     """
     p.setup(0.1)
     min_delay = p.get_min_delay()
     self.assertEqual(min_delay, 0.1)
예제 #11
0
 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)
예제 #12
0
def do_run():
    """
    test that tests the printing of v from a pre determined recording
    :return:
    """
    p.setup(timestep=0.04, min_delay=1.0, max_delay=4.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 = 1.7

    current_file_path = os.path.dirname(os.path.abspath(__file__))
    spikes_file = os.path.join(current_file_path, 'test.spikes')

    spikes = read_spikefile(spikes_file, n_neurons)
    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)

    p.end()

    return spikes
예제 #13
0
    def test_recording_numerious_element(self):
        p.setup(timestep=1.0, min_delay=1.0, max_delay=144.0)
        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()

        boxed_array = numpy.zeros(shape=(0, 2))
        spike_array = list()
        for neuron_id in range(0, n_neurons):
            spike_array.append(list())
            for counter in range(0, 20):
                random_time = random.randint(0, 5000)
                boxed_array = numpy.append(boxed_array,
                                           [[neuron_id, random_time]],
                                           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(5000)

        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()
예제 #14
0
def do_run(nNeurons):
    p.setup(timestep=1.0, min_delay=1.0, max_delay=32.0)
    p.set_number_of_neurons_per_core(IZK_curr_exp, 100)

    cell_params_izk = {
        'a': 0.02,
        'b': 0.2,
        'c': -65,
        'd': 8,
        'v_init': -75,
        'u_init': 0,
        'tau_syn_E': 2,
        'tau_syn_I': 2,
        'i_offset': 0
        }

    populations = list()
    projections = list()

    weight_to_spike = 40
    delay = 1

    connections = list()
    for i in range(0, nNeurons):
        singleConnection = (i, ((i + 1) % nNeurons), weight_to_spike, delay)
        connections.append(singleConnection)

    injectionConnection = [(0, 0, weight_to_spike, delay)]
    spikeArray = {'spike_times': [[50]]}
    populations.append(p.Population(nNeurons, IZK_curr_exp, cell_params_izk,
                                    label='pop_1'))
    populations.append(p.Population(1, p.SpikeSourceArray, spikeArray,
                                    label='inputSpikes_1'))

    projections.append(p.Projection(populations[0], populations[0],
                                    p.FromListConnector(connections)))
    projections.append(p.Projection(populations[1], populations[0],
                                    p.FromListConnector(injectionConnection)))

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

    p.run(500)

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

    p.end()

    return (v, gsyn, spikes)
 def test_tun(self):
     with self.assertRaises(SpinnmanTimeoutException):
         p.setup(timestep=1.0, min_delay=1.0, max_delay=144.0)
         # add to the path the location of the dodgy binary
         # (if_cur_exp with the c_main bodged to result in it
         # running for twice as long as expected)
         ex_finder = AbstractSpiNNakerCommon._EXECUTABLE_FINDER
         ex_finder.add_path(os.path.dirname(__file__))
         nNeurons = 200  # number of neurons in each population
         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 = 17
         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,
                          FakeIFCurrExp,
                          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)
         p.end()
예제 #16
0
def do_run():
    p.setup(timestep=1.0)
    input_pop = p.Population(1,
                             p.SpikeSourceArray,
                             cellparams={"spike_times": [0]},
                             label="input")
    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
    }
    pop = p.Population(2,
                       p.IF_curr_exp,
                       cellparams=cell_params_lif,
                       label="pop")

    connections = list()
    connections.append(
        p.Projection(input_pop, pop,
                     p.AllToAllConnector(weights=[0.3, 1.0], delays=[1, 17])))
    connections.append(
        p.Projection(input_pop, pop,
                     p.AllToAllConnector(weights=[1.0, 0.7], delays=[2, 15])))
    connections.append(
        p.Projection(input_pop, pop,
                     p.AllToAllConnector(weights=[0.7, 0.3], delays=[3, 33])))

    pre_weights = list()
    pre_delays = list()
    for connection in connections:
        pre_weights.append(connection.getWeights())
        pre_delays.append(connection.getDelays())

    p.run(100)

    post_weights = list()
    post_delays = list()
    for connection in connections:
        post_weights.append(connection.getWeights())
        post_delays.append(connection.getDelays())

    p.end()

    return (pre_weights, pre_delays, post_weights, post_delays)
예제 #17
0
    def test_run(self):
        sim.setup()

        sim.Population(3, sim.SpikeSourcePoisson, {"rate": 100})
        p2 = sim.Population(3, sim.SpikeSourceArray,
                            {"spike_times": [[10.0], [20.0], [30.0]]})
        p3 = sim.Population(4, sim.IF_cond_exp, {})

        sim.Projection(p2, p3, sim.FromListConnector([
            (0, 0, 0.1, 1.0), (1, 1, 0.1, 1.0), (2, 2, 0.1, 1.0)]))

        sim.run(100.0)

        sim.end()
def do_run(nNeurons):

    p.setup(timestep=0.1, min_delay=1.0, max_delay=7.5)
    p.set_number_of_neurons_per_core("IF_curr_exp", 100)

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

    populations = list()
    projections = list()

    weight_to_spike = 12
    injection_delay = 1
    delay = 1

    spikeArray = {'spike_times': [[0, 10, 20, 30]]}
    populations.append(
        p.Population(1, p.SpikeSourceArray, spikeArray, label='pop_0'))
    populations.append(
        p.Population(nNeurons, p.IF_curr_exp, cell_params_lif, label='pop_1'))
    populations.append(
        p.Population(nNeurons, p.IF_curr_exp, cell_params_lif, label='pop_2'))

    connector = p.AllToAllConnector(weights=weight_to_spike,
                                    delays=injection_delay)
    projections.append(p.Projection(populations[0], populations[1], connector))
    connector = p.OneToOneConnector(weights=weight_to_spike, delays=delay)
    projections.append(p.Projection(populations[1], populations[2], connector))

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

    p.run(100)

    v = populations[1].get_v(compatible_output=True)
    spikes = populations[1].getSpikes(compatible_output=True)

    p.end()

    return (v, spikes)
예제 #19
0
def do_run():
    p.setup(timestep=1.0, min_delay=1.0, max_delay=144.0)
    n_neurons = 900  # number of neurons in each population

    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
    }

    populations = list()
    projections = list()

    weight_to_spike = 2.0
    delay = 1

    populations.append(
        p.Population(n_neurons, p.IF_curr_exp, cell_params_lif, label='pop_1'))

    populations.append(
        p.Population(n_neurons, p.IF_curr_exp, cell_params_lif, label='pop_2'))

    connectors = p.AllToAllConnector(weights=weight_to_spike, delays=delay)
    projections.append(p.Projection(populations[0], populations[1],
                                    connectors))

    delays = []
    weights = []

    # before
    delays.append(projections[0].getDelays())
    weights.append(projections[0].getWeights())

    p.run(100)

    # after
    delays.append(projections[0].getDelays())
    weights.append(projections[0].getWeights())

    p.end()

    return (delays, weights)
예제 #20
0
def do_run():
    p.setup(timestep=1.0,
            min_delay=1.0,
            max_delay=10.0,
            db_name='if_cond.sqlite')

    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
    }

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

    spike_sourceE = p.Population(
        1,
        p.SpikeSourceArray,
        {'spike_times': [
            [i for i in range(5, 105, 10)],
        ]},
        label='spike_sourceE')

    p.Projection(spike_sourceE,
                 ifcell,
                 p.OneToOneConnector(weights=1, delays=2),
                 target='excitatory')
    breakMe = True
    if breakMe:
        p.Projection(spike_sourceE,
                     ifcell,
                     p.OneToOneConnector(weights=1, delays=2),
                     target='excitatory')

    ifcell.record_v()
    ifcell.record_gsyn()

    p.run(200.0)

    recorded_v = ifcell.get_v()
    recorded_gsyn = ifcell.get_gsyn()

    p.end()

    return (recorded_v, recorded_gsyn)
예제 #21
0
def do_run(split_spike_source_poisson=False,
           change_spike_rate=True,
           split_if_curr_exp=False,
           change_if_curr=True):
    p.setup(1.0)

    if split_spike_source_poisson:
        print "split SpikeSourcePoisson", split_spike_source_poisson
        p.set_number_of_neurons_per_core(p.SpikeSourcePoisson, 27)
    if split_if_curr_exp:
        print "split IF_curr_exp"
        p.set_number_of_neurons_per_core(p.IF_curr_exp, 22)

    inp = p.Population(100, p.SpikeSourcePoisson, {"rate": 100}, label="input")
    pop = p.Population(100, p.IF_curr_exp, {}, label="pop")

    p.Projection(inp, pop, p.OneToOneConnector(weights=5.0))

    pop.record()
    inp.record()

    p.run(100)

    if change_spike_rate:
        inp.set("rate", 10)
    if change_if_curr:
        # pop.set("cm", 0.25)
        pop.set("tau_syn_E", 1)

    p.run(100)

    pop_spikes1 = pop.getSpikes()
    inp_spikes1 = inp.getSpikes()

    p.reset()

    inp.set("rate", 0)
    pop.set("i_offset", 1.0)
    pop.initialize("v", p.RandomDistribution("uniform", [-65.0, -55.0]))
    p.run(100)

    pop_spikes2 = pop.getSpikes()
    inp_spikes2 = inp.getSpikes()

    p.end()

    return (pop_spikes1, inp_spikes1, pop_spikes2, inp_spikes2)
예제 #22
0
    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[1], populations[0],
                         p.AllToAllConnector()))

        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()
예제 #23
0
def do_run(nNeurons):
    p.setup(timestep=1.0, min_delay=1.0, max_delay=32.0)
    p.set_number_of_neurons_per_core("IF_curr_exp", 100)

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

    populations = list()
    projections = list()

    weight_to_spike = 2
    delay = 1

    connections = list()
    for i in range(0, nNeurons):
        singleConnection = (i, ((i + 1) % nNeurons), weight_to_spike, delay)
        connections.append(singleConnection)

    injectionConnection = [(0, 0, weight_to_spike, delay)]
    spikeArray = {'spike_times': [[0]]}
    for x in range(6):
        populations.append(
            p.Population(nNeurons, p.IF_curr_exp, cell_params_lif))
        populations.append(p.Population(1, p.SpikeSourceArray, spikeArray))

    for x in range(0, 12, 2):
        projections.append(
            p.Projection(populations[x], populations[x],
                         p.FromListConnector(connections)))
        connector = p.FromListConnector(injectionConnection)
        projections.append(
            p.Projection(populations[x + 1], populations[x], connector))
        populations[x].record()

    p.run(1000)

    p.end()
예제 #24
0
파일: test.py 프로젝트: chanokin/sPyNNaker7
def do_run(nNeurons):
    p.setup(timestep=1, min_delay=1, max_delay=15)

    nNeurons = 1  # number of neurons in each population

    neuron_parameters = {
        'cm': 0.25,
        'i_offset': 2,
        'tau_m': 10.0,
        'tau_refrac': 2.0,
        'tau_syn_E': 0.5,
        'tau_syn_I': 0.5,
        'v_reset': -65.0,
        'v_rest': -65.0,
        'v_thresh': -50.0
    }

    populations = list()

    populations.append(
        p.Population(nNeurons, p.IF_curr_exp, neuron_parameters,
                     label='pop_1'))
    populations.append(
        p.Population(nNeurons, p.IF_curr_exp, neuron_parameters,
                     label='pop_2'))
    populations[1].add_placement_constraint(x=1, y=0)

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

    p.run(100)

    v1 = populations[0].get_v()
    gsyn1 = populations[0].get_gsyn()
    spikes1 = populations[0].getSpikes()
    v2 = populations[0].get_v()
    gsyn2 = populations[0].get_gsyn()
    spikes2 = populations[0].getSpikes()

    p.end()

    return (v1, gsyn1, v2, gsyn2, spikes1, spikes2)
예제 #25
0
def setup(runtime):
    try:
        p.end()
    except ConfigurationException:
        pass
    p.setup(timestep=1)
    pop_1 = p.Population(1, p.IF_curr_exp, {}, label="pop_1")
    input = p.Population(1,
                         p.SpikeSourceArray, {'spike_times': [[0]]},
                         label="input")
    input_proj = p.Projection(input,
                              pop_1,
                              p.OneToOneConnector(weights=5.0, delays=1),
                              target="excitatory")
    assert input_proj is not None
    p.run(runtime)
    return (pop_1, input, input_proj)
예제 #26
0
def do_run(nNeurons):

    spike_list = {'spike_times': [11, 22]}
    print spike_list
    p.setup(timestep=1.0, min_delay=1.0, max_delay=32.0)

    pop = p.Population(nNeurons, p.SpikeSourceArray, spike_list, label='input')

    pop.record()

    p.run(200)

    spikes = pop.getSpikes(compatible_output=True)

    p.end()

    return spikes
    def test_run(self):
        with LogCapture() as l:
            p.setup()
            p1 = p.Population(1, p.IF_curr_exp, {})
            p2 = p.Population(1, p.IF_curr_exp, {})

            proj = p.Projection(p1, p2, p.AllToAllConnector())

            p.run(500)

            proj.getWeights()

            p.run(500)

            proj.getWeights()

            p.end()
            self.assert_logs_messages(l.records, "Getting weights", 'INFO', 2)
예제 #28
0
def do_run(nNeurons, _neurons_per_core):

    spike_list = {'spike_times': [float(x) for x in range(0, 599, 50)]}
    p.setup(timestep=1.0, min_delay=1.0, max_delay=32.0)

    p.set_number_of_neurons_per_core("SpikeSourceArray", _neurons_per_core)

    pop = p.Population(nNeurons, p.SpikeSourceArray, spike_list, label='input')

    pop.record()

    p.run(1000)

    spikes = pop.getSpikes(compatible_output=True)

    p.end()

    return spikes
예제 #29
0
def do_run():
    sim.setup(timestep=1)
    pop_1 = sim.Population(1, sim.IF_curr_exp, {}, label="pop_1")
    inp = sim.Population(1,
                         sim.SpikeSourceArray, {'spike_times': [[0]]},
                         label="input")
    sim.Projection(pop_1, pop_1, sim.OneToOneConnector(weights=5.0, delays=1))

    pop_1.record("spikes")
    sim.run(20)
    first_spikes = pop_1.getSpikes()

    sim.Projection(inp, pop_1, sim.FromListConnector([[0, 0, 5, 5]]))

    sim.reset()
    sim.run(20)
    second_spikes = pop_1.getSpikes()

    return first_spikes, second_spikes
예제 #30
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()