コード例 #1
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.extra_models.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.extra_models.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)
コード例 #2
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")
コード例 #3
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)
コード例 #4
0
 def connect_retina(retina,
                    network_topology_matrix,
                    block_l=None,
                    block_r=None):
     # since the network topology is a lower triangular matrix, iterating over the rows and removing the
     # artificially added -1 padding elements, yields the population ids in the network to which
     # a pixel from the left retina should be connected. The same is repeated for the right retina
     # but this time the network topology matrix is iterated along the columns.
     for pixel_id, row in enumerate(network_topology_matrix):
         for population_id in row[row >= 0]:
             pyNN.Projection(
                 presynaptic_population=retina[pixel_id],
                 postsynaptic_population=self._network['collectors']
                 [population_id],
                 connector=pyNN.OneToOneConnector(
                     weights=self.params['synapse']['wSC'],
                     delays=self.params['synapse']['dSC']),
                 target='excitatory')
             if block_l is not None and block_r is not None:
                 pyNN.Projection(
                     presynaptic_population=retina[pixel_id],
                     postsynaptic_population=self._network['blockers']
                     [population_id],
                     connector=pyNN.FromListConnector(block_l),
                     target='excitatory')
                 pyNN.Projection(
                     presynaptic_population=retina[pixel_id],
                     postsynaptic_population=self._network['blockers']
                     [population_id],
                     connector=pyNN.FromListConnector(block_r),
                     target='inhibitory')
コード例 #5
0
 def test_forever_projection(self):
     (pop_1, input, input_proj) = setup(None)
     with self.assertRaises(ConfigurationException):
         p.Projection(input,
                      pop_1,
                      p.OneToOneConnector(weights=5.0, delays=1),
                      target="excitatory")
コード例 #6
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.extra_models.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.extra_models.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)))
コード例 #7
0
 def test_source_populations_as_postsynaptic(self):
     global projections
     weight_to_spike = 2
     delay = 5
     with self.assertRaises(ConfigurationException):
         for i in range(4, 6):
             projections.append(
                 pyNN.Projection(
                     populations[0], populations[i],
                     pyNN.OneToOneConnector(weight_to_spike, delay)))
コード例 #8
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()
コード例 #9
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
コード例 #10
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')
        self.assertIsNotNone(s12_2)
        s21 = pyNN.Projection(p2,
                              p1,
                              pyNN.OneToOneConnector(weight_to_spike, delay),
                              target='excitatory')
        self.assertIsNotNone(s21)
コード例 #11
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")
     j = pyNN.Projection(p1, p2, pyNN.OneToOneConnector(weight, delay))
     self.assertIsNotNone(j)
コード例 #12
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")
     j = pyNN.Projection(different_population, second_population,
                         pyNN.OneToOneConnector(weight_to_spike, delay))
     self.assertIsNotNone(j)
コード例 #13
0
def do_run():
    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")
    p.Projection(input,
                 pop_1,
                 p.OneToOneConnector(weights=5.0, delays=1),
                 target="excitatory")
    p.Projection(pop_1,
                 pop_1,
                 p.OneToOneConnector(weights=5.0, delays=1),
                 target="excitatory")

    pop_1.record()
    p.run(20)
    spikes1 = pop_1.getSpikes()
    p.run(20)
    spikes2 = pop_1.getSpikes()
    p.run(100)
    spikes3 = pop_1.getSpikes()
    return (spikes1, spikes2, spikes3)
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)
コード例 #15
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)
コード例 #16
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)
コード例 #17
0
 def inhibit_along_eyesight(network_topology):
     for population_ids in network_topology:
         # generate population id pairs from all populations lying along the projection axis
         pairs = filter(
             lambda x: x[0] != x[1],
             it.product(population_ids[population_ids >= 0], repeat=2))
         logger.debug(
             "Generated inhibitory connection list for populations {}".
             format(pairs))
         for presynaptic, postsynaptic in pairs:
             pyNN.Projection(
                 presynaptic_population=self._network['collectors']
                 [presynaptic],
                 postsynaptic_population=self._network['collectors']
                 [postsynaptic],
                 connector=pyNN.OneToOneConnector(
                     weights=self.params['synapse']['wCCi'],
                     delays=self.params['synapse']['dCCi']),
                 target='inhibitory')
コード例 #18
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
コード例 #19
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()
コード例 #20
0
    def depress_cores(self, w_range=[-2.0, -1.5], d_range=[2.0, 2.0]):
        """Connect depressing noise sources to variables populations.

        args:
            w_range: range for the random distribution of synaptic weights in the form [w_min, w_max].
            d_range: range for the random distribution of synaptic delays in the form [d_min, d_max].
        """
        print msg, 'connecting Poisson noise sources to neural populations for dissipation'
        delays = RandomDistribution('uniform', d_range)
        weights = RandomDistribution('uniform', w_range)
        for depressor in range(self.d_populations):
            for variable in range(self.variables_number):
                if variable not in self.clues[0]:
                    synapses = p.Projection(
                        self.diss_pops[depressor][variable],
                        self.var_pops[variable],
                        p.OneToOneConnector(weights=weights, delays=delays),
                        target='inhibitory')
                    self.diss_conns.append(synapses)
        self.diss_times += self.disss
コード例 #21
0
    def stimulate_cores(self,
                        w_range=[1.4, 1.4],
                        d_range=[1.0, 1.0],
                        w_clues=[1.4, 1.6]):  # w_clues=[0.0, 0.2]
        """Connect stimulating noise sources to variables populations.

        args:
            w_range: range for the random distribution of synaptic weights in the form [w_min, w_max].
            d_range: range for the random distribution of synaptic delays in the form [d_min, d_max].
            w_clues: clues specific range for the random distribution of synaptic weights in the form [w_min, w_max].
        """
        p.set_number_of_neurons_per_core(p.IF_curr_exp, 150)
        print msg, 'connecting Poisson noise sources to neural populations for stimulation'
        delays = RandomDistribution('uniform', d_range)
        weights = RandomDistribution('uniform', w_range)
        weight_clues = RandomDistribution("uniform", w_clues)
        for stimulus in range(self.n_populations):
            for variable in range(self.variables_number):
                counter = 0
                if variable in self.clues[0]:
                    shift = self.clues[1][self.clues[0].index(
                        variable)] * self.core_size
                    connections = [(m, n + shift, weight_clues.next(),
                                    delays.next())
                                   for m in range(self.core_size)
                                   for n in range(self.clue_size)]
                    synapses = p.Projection(self.clues_stim[counter],
                                            self.var_pops[variable],
                                            p.FromListConnector(connections,
                                                                safe=True),
                                            target='excitatory')
                    counter += 1
                    self.stim_conns.append(synapses)
                else:
                    synapses = p.Projection(
                        self.stim_pops[stimulus][variable],
                        self.var_pops[variable],
                        p.OneToOneConnector(weights=weights, delays=delays),
                        target='excitatory')
                    self.stim_conns.append(synapses)
        self.stim_times += self.stims
コード例 #22
0
    def _apply_ordering_constraint(self):
        """
        Implement the proposed by Christoph ordering constraint of inhibiting possible *mirror* matches. 
        For example: | |a|b|c| - | |1|2|3|  -->  (a,3), (b,2), (c,1) could be sometimes prevented if (b,2)
        would inhibit (a,1) and (c,3) event types. These lie on the flipped diagonal of each population id.
         
        Returns:
            In-place method
        """
        logger.info(
            "Applying the ordering constraint on the temporal coincidence network."
        )

        # get all flipped diagonal population groups
        all_mirrored_diags = [
            self._network_topology[::-1, :].diagonal(i)
            for i in xrange(-self.max_disparity - 1, self.max_disparity + 2)
        ]
        valid_mirrored_diags = [
            group for group in [d[d >= 0] for d in all_mirrored_diags]
            if len(group) > 1
        ]
        for mirrored_diag in valid_mirrored_diags:
            for presynaptic, postsynaptic in pairs_of_neighbours(
                    mirrored_diag,
                    window_size=self.params['topology']['radius_ordering'] +
                    1):
                pyNN.Projection(
                    presynaptic_population=self._network['collectors']
                    [presynaptic],
                    postsynaptic_population=self._network['collectors']
                    [postsynaptic],
                    connector=pyNN.OneToOneConnector(
                        weights=self.params['synapse']['wCCo'],
                        delays=self.params['synapse']['dCCo']),
                    target='inhibitory')
        logger.debug(
            "Applying the ordering constraint on the temporal coincidence network completed."
        )
コード例 #23
0
def do_run():
    # this test ensures there is too much dtcm used up, thus crashes during
    # initisation
    p.setup(timestep=1.0, min_delay=1.0, max_delay=144.0)

    input = p.Population(1024, p.SpikeSourcePoisson, {'rate': 10}, "input")
    relay_on = p.Population(1024, p.IF_curr_exp, {}, "input")

    t_rule_LGN = p.SpikePairRule(tau_plus=17, tau_minus=34)
    w_rule_LGN = p.AdditiveWeightDependence(w_min=0.0,
                                            w_max=0.3,
                                            A_plus=0.01,
                                            A_minus=0.0085)
    stdp_model_LGN = p.STDPMechanism(timing_dependence=t_rule_LGN,
                                     weight_dependence=w_rule_LGN)
    s_d_LGN = p.SynapseDynamics(slow=stdp_model_LGN)
    p.Projection(input,
                 relay_on,
                 p.OneToOneConnector(weights=1),
                 synapse_dynamics=s_d_LGN,
                 target='excitatory')

    p.run(1000)
    p.end()
コード例 #24
0
                       [i[2] for i in v_for_neuron])


p.setup(time_step)

input_pop = p.Population(1,
                         p.SpikeSourceArray, {"spike_times": spike_times},
                         label="input")

my_model_pop = p.Population(1,
                            MyModelCurrExp, {
                                "my_parameter": -70.0,
                                "i_offset": i_offset,
                            },
                            label="my_model_pop")
p.Projection(input_pop, my_model_pop, p.OneToOneConnector(weights=weight))

my_model_my_synapse_type_pop = p.Population(
    1,
    MyModelCurrMySynapseType, {
        "my_parameter": -70.0,
        "i_offset": i_offset,
        "my_ex_synapse_parameter": 0.5
    },
    label="my_model_my_synapse_type_pop")
p.Projection(input_pop, my_model_my_synapse_type_pop,
             p.OneToOneConnector(weights=weight))

my_model_my_additional_input_pop = p.Population(
    1,
    MyModelCurrExpMyAdditionalInput, {
コード例 #25
0
if test_exc:
    target = sim.Population(num_exc, cell, exc_params, label='Target (EXC)')
else:
    target = sim.Population(num_exc, cell, inh_params, label='Target (INH)')

source.record()
target.record()
target.record_v()

########################################################################
# P R O J E C T I O N S
########################################################################

src_to_tgt = sim.Projection(source,
                            target,
                            sim.OneToOneConnector(weights=w2s,
                                                  generate_on_machine=True),
                            target='excitatory')

########################################################################
# R U N   S I M U L A T I O N
########################################################################

sim.run(sim_time)
spikes = {
    'target': target.getSpikes(compatible_output=True),
    'source': source.getSpikes(compatible_output=True),
}
voltage = target.get_v()
sim.end()

print("Total number of spikes %d" % (len(spikes['target'])))
コード例 #26
0
#    weight_dependence = sim.AdditiveWeightDependence(w_min=1.0, w_max=15.0, A_plus=0.1, A_minus=0.1)
#)


# Connections between spike sources and neuron populations
    ####### SET HERE THE PARALLEL FIBER-PURKINJE CELL LEARNING RULE
ee_connector = sim.AllToAllConnector(weights=1.0)
projection_pf = sim.Projection(pre_stim, population, ee_connector,
                                         synapse_dynamics=sim.SynapseDynamics(slow=stdp_model),
                                         target='excitatory')

                                         
proj2 = sim.Projection(pre_stim, population2, ee_connector,target='excitatory')

# SET HERE THE TEACHING SIGNAL PROJECTION
ee_connector = sim.OneToOneConnector(weights=0.0)
proj_teaching = sim.Projection(teaching_stim, population, ee_connector, target='supervision')
#proj_dummy = sim.Projection(dummy_stim,population,sim.OneToOneConnector(weights=1000.1), target='inhibitory')

#IPython.embed()

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

# Run simulation
sim.run(sim_time)

# Get weight from each projection
end_w = projection_pf.getWeights() #[p.getWeights()[0] for p in projections_pf]
print end_w

# -------------------------------------------------------------------
コード例 #27
0
    def _apply_continuity_constraint(self):
        """
        Implement the David Marr's continuity constraint which encourages the spiking of disparity sensitive neurons 
        which lie in the same disparity map. This is backed by the assumption that physical object are coherent 
        and disparity does not change by much (if at all).
        
        Returns:
            In-place method
        """
        logger.info(
            "Applying the continuity constraint on the temporal coincidence network."
        )
        logger.warning(
            "The current implementation supports only cross-like connection patterns, "
            "i.e. a neuron will excite only neurons to the left, right, top and bottom. "
        )

        if self.params['topology']['radius_continuity'] > self.retina_n_cols:
            new_radius = 1
            logger.warning(
                "Radius of excitation is too big. Setting radius to {}".format(
                    new_radius))
            self.params['topology']['radius_continuity'] = new_radius

        logger.debug("Same-disparity population ids: {}".format(
            list(self._same_disparity_populations)))

        # iterate over population or neural ids and construct pairs from neighbouring units
        for population_ids in self._same_disparity_populations:
            for presynaptic, postsynaptic in pairs_of_neighbours(
                    population_ids,
                    window_size=self.params['topology']['radius_continuity'] +
                    1,
                    add_reciprocal=True):
                pyNN.Projection(
                    presynaptic_population=self._network['collectors']
                    [presynaptic],
                    postsynaptic_population=self._network['collectors']
                    [postsynaptic],
                    connector=pyNN.OneToOneConnector(
                        weights=self.params['synapse']['wCCe'],
                        delays=self.params['synapse']['dCCe']),
                    target='excitatory')

        # construct vertical connections within each neural population
        within_population_neuron_pairs = pairs_of_neighbours(
            range(self.retina_n_rows),
            window_size=self.params['topology']['radius_continuity'] + 1,
            add_reciprocal=True)
        logger.debug("Within-population neuron pairs: {}".format(
            within_population_neuron_pairs))

        connection_list = [(src, dst, self.params['synapse']['wCCe'],
                            self.params['synapse']['dCCe'])
                           for src, dst in within_population_neuron_pairs]
        if len(self._network['collectors']) > 1 and len(connection_list) > 0:
            for population in self._network['collectors']:
                pyNN.Projection(
                    presynaptic_population=population,
                    postsynaptic_population=population,
                    connector=pyNN.FromListConnector(connection_list),
                    target='excitatory')
        logger.debug(
            "Applying the continuity constraint on the temporal coincidence network completed."
        )
コード例 #28
0
                                            use_payload_prefix=False)
# populations.append(Population(nNeurons,
#                               IF_curr_exp, cell_params_lif,
#                               label='pop_%d' % i))

pop_external = p.Population(nNeurons,
                            p.external_devices.SpikeInjector,
                            cell_params_ext_dev,
                            label='Babel_Dummy')

populations.append(
    p.Population(nNeurons, p.IF_curr_exp, cell_params_lif, label='pop_%d' % 1))

projections.append(
    p.Projection(pop_external, populations[1],
                 p.OneToOneConnector(weights=weight_to_spike, delays=10)))

# populations[0].record_v()
#  at the moment is only possible to observe one population per core
populations[1].record_v()

for pop in populations:
    pop.record(to_file=False)  # sends spike to the Monitoring application

#    populations[i].record_variable('rate', save_to='eth')
#  sends spike to the Monitoring application

p.run(10000)

# retrieving spike results and plotting...
コード例 #29
0
def do_run():
    # SpiNNaker setup
    p.setup(timestep=1.0, min_delay=1.0, max_delay=10.0)

    # +-------------------------------------------------------------------+
    # | General Parameters                                                |
    # +-------------------------------------------------------------------+

    # Population parameters
    model = p.IF_curr_exp
    # model = sim.IF_cond_exp
    """
    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}
    """
    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
    }

    # Other simulation parameters
    e_rate = 200
    in_rate = 350

    n_stim_test = 5
    n_stim_pairing = 10
    dur_stim = 20

    pop_size = 40

    ISI = 150.
    start_test_pre_pairing = 200.
    start_pairing = 1500.
    start_test_post_pairing = 700.

    simtime = start_pairing + start_test_post_pairing + \
        ISI * (n_stim_pairing + n_stim_test) + 550.  # let's make it 5000

    # Initialisations of the different types of populations
    IAddPre = []
    IAddPost = []

    # +-------------------------------------------------------------------+
    # | Creation of neuron populations                                    |
    # +-------------------------------------------------------------------+

    # Neuron populations
    pre_pop = p.Population(pop_size, model, cell_params)
    post_pop = p.Population(pop_size, model, cell_params)

    # Test of the effect of activity of the pre_pop population on the post_pop
    # population prior to the "pairing" protocol : only pre_pop is stimulated
    for i in range(n_stim_test):
        IAddPre.append(
            p.Population(
                pop_size, p.SpikeSourcePoisson, {
                    'rate': in_rate,
                    'start': start_test_pre_pairing + ISI * (i),
                    'duration': dur_stim
                }))

    # Pairing protocol : pre_pop and post_pop are stimulated with a 10 ms
    # difference
    for i in range(n_stim_pairing):
        IAddPre.append(
            p.Population(
                pop_size, p.SpikeSourcePoisson, {
                    'rate': in_rate,
                    'start': start_pairing + ISI * (i),
                    'duration': dur_stim
                }))
        IAddPost.append(
            p.Population(
                pop_size, p.SpikeSourcePoisson, {
                    'rate': in_rate,
                    'start': start_pairing + ISI * (i) + 10.,
                    'duration': dur_stim
                }))

    # Test post pairing : only pre_pop is stimulated
    # (and should trigger activity in Post)
    for i in range(n_stim_test):
        start = start_pairing + ISI * n_stim_pairing + \
                start_test_post_pairing + ISI * i
        IAddPre.append(
            p.Population(pop_size, p.SpikeSourcePoisson, {
                'rate': in_rate,
                'start': start,
                'duration': dur_stim
            }))

    # Noise inputs
    INoisePre = p.Population(pop_size,
                             p.SpikeSourcePoisson, {
                                 'rate': e_rate,
                                 'start': 0,
                                 'duration': simtime
                             },
                             label="expoisson")
    params = {'rate': e_rate, 'start': 0, 'duration': simtime}
    INoisePost = p.Population(pop_size,
                              p.SpikeSourcePoisson,
                              params,
                              label="expoisson")

    # +-------------------------------------------------------------------+
    # | Creation of connections                                           |
    # +-------------------------------------------------------------------+

    # Connection parameters
    JEE = 3.

    # Connection type between noise poisson generator and
    # excitatory populations
    ee_connector = p.OneToOneConnector(weights=JEE * 0.05)

    # Noise projections
    p.Projection(INoisePre, pre_pop, ee_connector, target='excitatory')
    p.Projection(INoisePost, post_pop, ee_connector, target='excitatory')

    # Additional Inputs projections
    for i in range(len(IAddPre)):
        p.Projection(IAddPre[i], pre_pop, ee_connector, target='excitatory')
    for i in range(len(IAddPost)):
        p.Projection(IAddPost[i], post_pop, ee_connector, target='excitatory')

    # Plastic Connections between pre_pop and post_pop
    timing_dependence = p.SpikePairRule(tau_plus=20., tau_minus=50.0)
    weight_dependence = p.AdditiveWeightDependence(w_min=0,
                                                   w_max=0.9,
                                                   A_plus=0.02,
                                                   A_minus=0.02)
    stdp_model = p.STDPMechanism(timing_dependence=timing_dependence,
                                 weight_dependence=weight_dependence)

    plastic_projection = \
        p.Projection(pre_pop, post_pop,
                     p.FixedProbabilityConnector(p_connect=0.5),
                     synapse_dynamics=p.SynapseDynamics(slow=stdp_model)
                     )

    # +-------------------------------------------------------------------+
    # | Simulation and results                                            |
    # +-------------------------------------------------------------------+

    # Record neurons' potentials
    pre_pop.record_v()
    post_pop.record_v()

    # Record spikes
    pre_pop.record()
    post_pop.record()

    # Run simulation
    p.run(simtime)

    weights = plastic_projection.getWeights()

    pre_spikes = pre_pop.getSpikes(compatible_output=True)
    post_spikes = post_pop.getSpikes(compatible_output=True)

    p.end()

    return (weights, pre_spikes, post_spikes)
コード例 #30
0
def do_run(nNeurons, neurons_per_core):

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

    nPopulations = 62
    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 = 1.5
    delay = 5

    for i in range(0, nPopulations):
        populations.append(
            p.Population(nNeurons,
                         p.IF_curr_exp,
                         cell_params_lif,
                         label='pop_' + str(i)))
        # print "++++++++++++++++"
        # print "Added population %s" % (i)
        # print "o-o-o-o-o-o-o-o-"
    for i in range(0, nPopulations):
        projections.append(
            p.Projection(populations[i],
                         populations[(i + 1) % nPopulations],
                         p.OneToOneConnector(weight_to_spike, delay),
                         label="Projection from pop {} to pop "
                         "{}".format(i, (i + 1) % nPopulations)))
        # print "++++++++++++++++++++++++++++++++++++++++++++++++++++"
        # print "Added projection from population %s to population %s" \
        #       % (i, (i + 1) % nPopulations)

        # print "----------------------------------------------------"

    # pp(projections)
    spikeArray = {'spike_times': [[0]]}
    populations.append(
        p.Population(1, p.SpikeSourceArray, spikeArray, label='inputSpikes_1'))
    projections.append(
        p.Projection(populations[-1], populations[0],
                     p.AllToAllConnector(weight_to_spike, delay)))

    for i in range(0, nPopulations):
        populations[i].record_v()
        populations[i].record_gsyn()
        populations[i].record()

    p.run(1500)

    v = None
    gsyn = None
    spikes = None
    ''''
    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)