コード例 #1
0
 def test_multiple_connections_between_same_populations(self):
     p1 = pyNN.Population(no_neurons,
                          pyNN.IF_curr_exp,
                          cell_params_lif,
                          label="LIF Pop")
     p2 = pyNN.Population(no_neurons,
                          pyNN.IF_curr_exp,
                          cell_params_lif,
                          label="LIF Pop")
     pyNN.Projection(p1, p2, pyNN.OneToOneConnector(1, 1))
     self.assertIsInstance(
         pyNN.Projection(p1, p2, pyNN.OneToOneConnector(1, 1)), Projection,
         "Failed to create multiple connections between"
         " the same pair of populations")
コード例 #2
0
    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=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
コード例 #3
0
 def test_source_populations_as_postsynaptic(self):
     global projections
     weight_to_spike = 2
     delay = 5
     with self.assertRaises(exc.ConfigurationException):
         for i in range(4, 6):
             projections.append(
                 pyNN.Projection(
                     populations[0], populations[i],
                     pyNN.OneToOneConnector(weight_to_spike, delay)))
コード例 #4
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 random_time in range(0, 20):
                random_time2 = random.randint(0, 5000)
                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(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()
コード例 #5
0
    def test_inhibitory_connector(self):
        weight_to_spike = 2
        delay = 5
        p1 = pyNN.Population(no_neurons,
                             pyNN.IF_curr_exp,
                             cell_params_lif,
                             label="LIF Pop")
        p2 = pyNN.Population(no_neurons,
                             pyNN.IF_curr_exp,
                             cell_params_lif,
                             label="LIF Pop")

        s12_2 = pyNN.Projection(p1,
                                p2,
                                pyNN.OneToOneConnector(weight_to_spike, delay),
                                target='inhibitory')
        s21 = pyNN.Projection(p2,
                              p1,
                              pyNN.OneToOneConnector(weight_to_spike, delay),
                              target='excitatory')
コード例 #6
0
 def test_nasty(self):
     weight = 2
     delay = 1
     first_pop = pyNN.Population(5,
                                 pyNN.IF_curr_exp,
                                 cell_params_lif,
                                 label="First normal pop")
     pyNN.Projection(
         first_pop, first_pop,
         pyNN.MultapseConnector(num_synapses=10,
                                weights=weight,
                                delays=delay))
コード例 #7
0
 def test_connector_populations_of_different_sizes(self):
     weight = 2
     delay = 5
     p1 = pyNN.Population(10,
                          pyNN.IF_curr_exp,
                          cell_params_lif,
                          label="pop 1")
     p2 = pyNN.Population(5,
                          pyNN.IF_curr_exp,
                          cell_params_lif,
                          label="pop 2")
     with self.assertRaises(ConfigurationException):
         pyNN.Projection(p1, p2, pyNN.OneToOneConnector(weight, delay))
コード例 #8
0
    def test_projection_params(self):
        populations = list()
        projection_details = list()
        populations = list()
        weight_to_spike = 2
        delay = 5
        populations.append(
            pyNN.Population(no_neurons,
                            pyNN.IF_curr_exp,
                            cell_params_lif,
                            label="LIF Pop"))
        populations.append(
            pyNN.Population(no_neurons,
                            pyNN.IF_curr_dual_exp,
                            cell_params_lif2exp,
                            label="IF_curr_dual_exp Pop"))
        populations.append(
            pyNN.Population(no_neurons,
                            pyNN.IF_cond_exp,
                            cell_params_lifexp,
                            label="IF_cond_exp Pop"))
        populations.append(
            pyNN.Population(no_neurons,
                            pyNN.IZK_curr_exp,
                            cell_params_izk,
                            label="IZK_curr_exp Pop"))

        for i in range(4):
            for j in range(4):
                projection_details.append({
                    'presyn':
                    populations[i],
                    'postsyn':
                    populations[j],
                    'connector':
                    pyNN.OneToOneConnector(weight_to_spike, delay)
                })
                projections.append(
                    pyNN.Projection(
                        populations[i], populations[j],
                        pyNN.OneToOneConnector(weight_to_spike, delay)))

        for i in range(4):
            for j in range(4):
                self.assertEqual(
                    projections[i + j]._projection_edge._pre_vertex,
                    projection_details[i + j]['presyn']._vertex)
                self.assertEqual(
                    projections[i + j]._projection_edge._post_vertex,
                    projection_details[i + j]['postsyn']._vertex)
コード例 #9
0
 def test_one_to_one_connector_from_high_to_low(self):
     weight_to_spike, delay = 2, 5
     second_population = pyNN.Population(no_neurons,
                                         pyNN.IF_curr_exp,
                                         cell_params_lif,
                                         label="LIF Pop")
     different_population = pyNN.Population(
         20,
         pyNN.IF_curr_exp,
         cell_params_lif,
         label="A random sized population")
     with self.assertRaises(exc.ConfigurationException):
         pyNN.Projection(different_population, second_population,
                         pyNN.OneToOneConnector(weight_to_spike, delay))
コード例 #10
0
 def test_setup(self):
     global projections
     weight_to_spike = 2
     delay = 5
     populations.append(
         pyNN.Population(no_neurons,
                         pyNN.IF_curr_exp,
                         cell_params_lif,
                         label="LIF Pop"))
     populations.append(
         pyNN.Population(no_neurons,
                         pyNN.IF_curr_dual_exp,
                         cell_params_lif2exp,
                         label="IF_curr_dual_exp Pop"))
     populations.append(
         pyNN.Population(no_neurons,
                         pyNN.IF_cond_exp,
                         cell_params_lifexp,
                         label="IF_cond_exp Pop"))
     populations.append(
         pyNN.Population(no_neurons,
                         pyNN.IZK_curr_exp,
                         cell_params_izk,
                         label="IZK_curr_exp Pop"))
     populations.append(
         pyNN.Population(no_neurons,
                         pyNN.SpikeSourceArray,
                         spike_array,
                         label="SpikeSourceArray Pop"))
     populations.append(
         pyNN.Population(no_neurons,
                         pyNN.SpikeSourcePoisson,
                         spike_array_poisson,
                         label="SpikeSourcePoisson Pop"))
     for i in range(4):
         projection_details.append({
             'presyn':
             populations[0],
             'postsyn':
             populations[i],
             'connector':
             pyNN.OneToOneConnector(weight_to_spike, delay)
         })
         projections.append(
             pyNN.Projection(populations[0], populations[i],
                             pyNN.OneToOneConnector(weight_to_spike,
                                                    delay)))
コード例 #11
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()
コード例 #12
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()
コード例 #13
0
    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
コード例 #14
0
    def _interconnect_neurons(self, network, verbose=False):

        assert network is not None, \
            "ERROR: Network is not initialised! Interconnecting failed."

        synaptic_params = self.cell_params['synaptic']

        # generate connectivity list: 0 untill dimensionRetinaY-1 for the left
        # and dimensionRetinaY till dimensionRetinaY*2 - 1 for the right
        connList = []
        for y in range(0, self.dim_y):
            connList.append(
                (y, y, synaptic_params['wBC'], synaptic_params['dBC']))
            connList.append((y + self.dim_y, y, synaptic_params['wBC'],
                             synaptic_params['dBC']))

        # connect the inhibitory neurons to the cell output neurons
        if verbose:
            print "INFO: Interconnecting Neurons. This may take a while."
        for ensemble in network:
            ps.Projection(ensemble[0],
                          ensemble[1],
                          ps.FromListConnector(connList),
                          target='inhibitory')
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, 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)
コード例 #16
0
    def test_get_voltage(self):
        """
        test that tests the getting of v from a pre determined recording
        :return:
        """
        p.setup(timestep=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))
コード例 #17
0
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, input_cell_params, 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'))

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

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

p.run(100)

v = None
gsyn = None
spikes = None
コード例 #18
0
    len(indices_pos_exc))[temp_exc_pos == 1]  # excitatory ones
exc2inh = numpy.arange(
    len(indices_pos_exc))[temp_exc_pos == 0]  # inhibitory ones

# EXC2EXC
indices_pre_exc_e2e = [(numpy.abs(exc_neuron_idx - i)).argmin()
                       for i in indices_pre_exc[exc2exc]]
indices_pos_exc_e2e = [(numpy.abs(exc_neuron_idx - i)).argmin()
                       for i in indices_pos_exc[exc2exc]]

connections_exc2exc = sim.FromListConnector(conn_list=zip(
    indices_pre_exc_e2e, indices_pos_exc_e2e, weights_pre_exc[exc2exc], [0.0] *
    len(exc2exc)))
sim.Projection(pop_lsm_exc,
               pop_lsm_exc,
               connections_exc2exc,
               label="EXC2EXC_conn",
               target='excitatory')

# EXC2INH
indices_pre_exc_e2i = [(numpy.abs(inh_neuron_idx - i)).argmin()
                       for i in indices_pre_exc[exc2inh]]
indices_pos_exc_e2i = [(numpy.abs(inh_neuron_idx - i)).argmin()
                       for i in indices_pos_exc[exc2inh]]

connections_exc2inh = sim.FromListConnector(conn_list=zip(
    indices_pre_exc_e2i, indices_pos_exc_e2i, weights_pre_exc[exc2inh], [0.0] *
    len(exc2inh)))
sim.Projection(pop_lsm_exc,
               pop_lsm_inh,
               connections_exc2inh,
コード例 #19
0
                                label='in_cur_esp1'))
populations[population_index].set_mapping_constraint({'x':0, 'y':0})
population_index += 1
populations.append(p.Population(nNeurons, p.IF_curr_exp, cell_params_lif,
                                label='in_cur_esp2'))
populations[population_index].set_mapping_constraint({'x':7, 'y':7})
population_index += 1


#upwards path

for processor in range(2, 16):
    populations.append(p.Population(nNeurons, p.SpikeSourceArray, spikeArray,
                                    label='inputSpikes_2:{}'.format(processor)))
    populations[population_index].set_mapping_constraint({'x':0, 'y':0})
    projections.append(p.Projection(populations[population_index],
                                    populations[0], p.AllToAllConnector()))
    population_index += 1
for processor in range(2, 16):
    populations.append(p.Population(nNeurons, p.SpikeSourceArray, spikeArray,
                                    label='inputSpikes_2:{}'.format(processor)))
    populations[population_index].set_mapping_constraint({'x':1, 'y':1})
    projections.append(p.Projection(populations[population_index],
                                    populations[0], p.AllToAllConnector()))
    population_index += 1
for processor in range(2, 16):
    populations.append(p.Population(nNeurons, p.SpikeSourceArray, spikeArray,
                                    label='inputSpikes_2:{}'.format(processor)))
    populations[population_index].set_mapping_constraint({'x':2, 'y':2})
    projections.append(p.Projection(populations[population_index],
                                    populations[0], p.AllToAllConnector()))
    population_index += 1
コード例 #20
0
# spindle population
spindle_pop = p.Population(n_fibers * 2,
                           MuscleSpindle, {
                               "primary": [1] * n_fibers + [0] * n_fibers,
                               "v_thresh": 100.0,
                               "receive_port": 12345
                           },
                           label="spindle_pop")

spindle_pop.record()

# dynamic fusimotor drive
gamma_dyn = p.Population(1, p.SpikeSourcePoisson, {'rate': 70.0})
p.Projection(gamma_dyn,
             spindle_pop,
             p.OneToOneConnector(weights=weight),
             target="dynamic")

# static fusimotor drive
gamma_st = p.Population(1, p.SpikeSourcePoisson, {'rate': 40.0})
p.Projection(gamma_st,
             spindle_pop,
             p.OneToOneConnector(weights=weight),
             target="static")

# database for live communication
spynnaker_external_devices = SpynnakerExternalDevicePluginManager()


def create_database():
    database_notify_port_num = conf.config.getint("Database", "notify_port")
コード例 #21
0
    ros_topic_recv='from_spinnaker',
    output_population=readout_neurons,
    clk_rate=1000,
    ros_output_rate=10)

#======================================================
#===
#===        Define Neural Projections
#===
#======================================================

# Build your network, run the simulation and optionally record the spikes and voltages.
rconn = 0.1
ext_conn = FixedProbabilityConnector(rconn, weights=0.1)

pynn.Projection(input_interface, reservoir,
                pynn.AllToAllConnector(weights=0.5, delays=1))

pynn.Projection(reservoir, readout_neurons,
                pynn.AllToAllConnector(weights=0.5, delays=1))

readout_neurons.record()
readout_neurons.record_v()

# run the network and measure the time it takes
timer.start()

pynn.run(simulation_time)

simCPUTime = timer.diff()

spikes = readout_neurons.getSpikes()
コード例 #22
0
        (x_u, y_u, p_u, ts_u))

#Let us only use the ON events
TrianSpikeON = BuildTrainingSpike(test_order, 1)
spikeArrayOn = {'spike_times': TrianSpikeON}
ON_pop = sim.Population(prepop_size,
                        sim.SpikeSourceArray,
                        spikeArrayOn,
                        label='inputSpikes_On')
post_pop = sim.Population(postpop_size,
                          sim.IF_curr_exp,
                          cell_params_lif,
                          label='post_1')

connectionsOn = sim.Projection(
    ON_pop, post_pop,
    sim.FromListConnector(convert_weights_to_list(weights_import, delay)))
#inhibitory between the neurons
connection_I = sim.Projection(post_pop,
                              post_pop,
                              sim.AllToAllConnector(weights=0.08, delays=1),
                              target='inhibitory')
post_pop.record()
sim.run(simtime)

# == Get the Simulated Data =================================================
post_spikes = post_pop.getSpikes(compatible_output=True)
sim.end()


def GetFiringPattern(spike, low, high):
コード例 #23
0
                                   Frontend.IF_curr_exp,
                                   cell_params_lif,
                                   label='pop_backward')

# Create injection populations
injector_forward = Frontend.Population(n_neurons,
                                       ExternalDevices.SpikeInjector,
                                       cell_params_spike_injector_with_key,
                                       label='spike_injector_forward')
injector_backward = Frontend.Population(n_neurons,
                                        ExternalDevices.SpikeInjector,
                                        cell_params_spike_injector,
                                        label='spike_injector_backward')

# Create a connection from the injector into the populations
Frontend.Projection(injector_forward, pop_forward,
                    Frontend.OneToOneConnector(weights=weight_to_spike))
Frontend.Projection(injector_backward, pop_backward,
                    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
# reaches the end
loop_forward = list()
loop_backward = list()
for i in range(0, n_neurons - 1):
    loop_forward.append((i, (i + 1) % n_neurons, weight_to_spike, 3))
    loop_backward.append(((i + 1) % n_neurons, i, weight_to_spike, 3))
Frontend.Projection(pop_forward, pop_forward,
                    Frontend.FromListConnector(loop_forward))
Frontend.Projection(pop_backward, pop_backward,
                    Frontend.FromListConnector(loop_backward))
コード例 #24
0
populations.append(
    p.Population(nNeurons, p.IF_cond_exp, cell_params_cond, label='pop_cond'))
populations.append(
    p.Population(1, p.SpikeSourceArray, spikeArray, label='inputSpikes_1'))

populations.append(
    p.Population(nNeurons, p.IF_curr_exp, cell_params_lif, label='pop_curr'))
populations.append(
    p.Population(1, p.SpikeSourceArray, spikeArray, label='inputSpikes_2'))

populations.append(
    p.Population(nNeurons, p.IF_curr_exp, cell_params_lif, label='sink_pop'))

projections.append(
    p.Projection(populations[1], populations[0],
                 p.FromListConnector(injectionConnection)))
projections.append(
    p.Projection(populations[3], populations[2],
                 p.FromListConnector(injectionConnection)))
projections.append(
    p.Projection(populations[0], populations[4],
                 p.FromListConnector(sinkConnection)))
projections.append(
    p.Projection(populations[2], populations[4],
                 p.FromListConnector(sinkConnection)))
populations[0].record_v()
populations[0].record_gsyn()
populations[0].record()

populations[2].record_v()
populations[2].record_gsyn()
コード例 #25
0
spikeArray = {'spike_times': [[0]]}

for i in range(0, n_pops):
    populations.append(
        p.Population(nNeurons,
                     p.IF_curr_exp,
                     cell_params_lif,
                     label='pop_{}'.format(i)))

populations.append(
    p.Population(1, p.SpikeSourceArray, spikeArray, label='inputSpikes_1'))

for i in range(0, n_pops):
    projections.append(
        p.Projection(populations[i], populations[i],
                     p.FromListConnector(connections)))
    projections.append(
        p.Projection(populations[i], populations[((i + 1) % n_pops)],
                     p.FromListConnector(pop_jump_connection)))

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

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

for pop_index in range(0, n_pops):
    populations[pop_index].record()

p.run(25000)
コード例 #26
0
projections = list()

weight_to_spike = 2.0
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, 1)]
spikeArray = {'spike_times': [[0]]}
populations.append(p.Population(nNeurons, p.IF_curr_exp, cell_params_lif, label='pop_1'))
populations[0].set_constraint(p.PlacerChipAndCoreConstraint(x=0, y=0, p=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(100)

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)
コード例 #27
0
ファイル: stdp_triplet.py プロジェクト: ominux/sPyNNaker
            f, start_time + t, num_pairs)
        pre_stim = sim.Population(1, sim.SpikeSourceArray,
                                  {'spike_times': [
                                      pre_times,
                                  ]})
        post_stim = sim.Population(1, sim.SpikeSourceArray,
                                   {'spike_times': [
                                       post_times,
                                   ]})

        # Update simulation time
        sim_time = max(sim_time, max(max(pre_times), max(post_times)) + 100)

        # Connections between spike sources and neuron populations
        ee_connector = sim.OneToOneConnector(weights=2)
        sim.Projection(pre_stim, pre_pop, ee_connector, target='excitatory')
        sim.Projection(post_stim, post_pop, ee_connector, target='excitatory')

        # **HACK**
        param_scale = 0.5

        # 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,
コード例 #28
0
populations = list()
projections = list()

weight_to_spike = 2
#delay = 3.1
injection_delay = 2
delay = 10

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.AllToAllConnector(weights=weight_to_spike, delays=delay)))
projections.append(
    p.Projection(populations[1], populations[0],
                 p.FromListConnector([(0, 0, 4, injection_delay)])))

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

p.run(90)

v = None
gsyn = None
spikes = None

v = populations[0].get_v(compatible_output=True)
spikes = populations[0].getSpikes(compatible_output=True)
コード例 #29
0
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()
コード例 #30
0
pynn.setup(timestep=ts, min_delay=ts, max_delay=2.0 * ts)

pop = pynn.Population(size=n_neurons,
                      cellclass=pynn.IF_curr_exp,
                      cellparams={},
                      label='pop')

# The ROS_Spinnaker_Interface just needs to be initialised with these two Spike Source Parameters.
ros_interface = ROS_Spinnaker_Interface(
    n_neurons_source=n_neurons,  # number of neurons of the injector population
    Spike_Source_Class=SpikeSourcePoisson
)  # the transfer function ROS Input -> Spikes you want to use.

# Build your network, run the simulation and optionally record the spikes and voltages.
pynn.Projection(ros_interface, pop, pynn.OneToOneConnector(weights=5,
                                                           delays=1))

pop.record()
pop.record_v()

pynn.run(simulation_time)

spikes = pop.getSpikes()

pynn.end()

# Plot
import pylab

spike_times = [spike[1] for spike in spikes]
spike_ids = [spike[0] for spike in spikes]