コード例 #1
0
    def test_pynn_basic(self):
        pass
        """
        TODO figure out how to take machine name as a parameter
        """
        print "test_pynn_basic setup....."
        pynn.setup(**{'machine': 'spinn-7'})

        n_atoms = 10

        proj1_params = {
            'source': None,
            'delays': 1,
            'weights': 1,
            'target': 'excitatory'
        }
        proj2_params = {
            'allow_self_connections': True,
            'delays': 2,
            'p_connect': 0.1,
            'weights': 2,
            'source': None,
            'target': None
        }

        cell_params = {
            'tau_m': 64,
            'v_init': -75,
            'i_offset': 0,
            'v_rest': -75,
            'v_reset': -95,
            'v_thresh': -40,
            'tau_syn_E': 15,
            'tau_syn_I': 15,
            'tau_refrac': 10
        }

        pop1 = pynn.Population(n_atoms,
                               pynn.IF_curr_exp,
                               cell_params,
                               label='pop1')
        pop2 = pynn.Population(n_atoms * 2,
                               pynn.IF_curr_exp,
                               cell_params,
                               label='pop2')

        proj1 = pynn.Projection(pop1,
                                pop2,
                                pynn.OneToOneConnector(weights=1, delays=1),
                                target='excitatory')
        proj2 = pynn.Projection(
            pop1, pop2,
            pynn.FixedProbabilityConnector(weights=2, delays=2, p_connect=.1))

        pynn.controller.map_model()  # at this stage the model is mapped
        print "checking vertices..."
        self.assertEqual(pop1.vertex.parameters, cell_params)
        self.assertEqual(pynn.controller.dao.vertices[1].parameters,
                         cell_params)

        self.assertEqual(pop1.vertex.model,
                         pacman103.front.pynn.models.IF_curr_exp)
        self.assertEqual(pynn.controller.dao.vertices[0].label, "pop1")
        self.assertEqual(pynn.controller.dao.vertices[1].label, "pop2")

        self.assertEqual(pop1.vertex.atoms, n_atoms)
        self.assertEqual(pynn.controller.dao.vertices[1].atoms, n_atoms * 2)

        print "checking edges..."
        self.assertEqual(pynn.controller.dao.edges[0].model,
                         pacman103.front.pynn.connectors.OneToOneConnector)
        self.assertEqual(
            proj2.edge.model,
            pacman103.front.pynn.connectors.FixedProbabilityConnector)

        self.assertEqual(proj1.edge.parameters, proj1_params)
        self.assertEqual(pynn.controller.dao.edges[1].parameters, proj2_params)

        # testing the mapping phase
        self.assertEqual(len(pynn.controller.dao.subedges), 2)
        self.assertEqual(len(pynn.controller.dao.subvertices), 2)

        self.assertEqual(len(pynn.controller.dao.routings), 2)

        #        pynn.run(100)
        pynn.end()
コード例 #2
0
                            sim.SpikeSourcePoisson, {
                                'rate': e_rate,
                                'start': 0,
                                'duration': simtime
                            },
                            label="expoisson")

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

# Connection parameters
JEE = 3.

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

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

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

# Plastic Connections between pre_pop and post_pop
stdp_model = sim.STDPMechanism(
    timing_dependence=sim.SpikePairRule(tau_plus=20.,
                                        tau_minus=50.0,
コード例 #3
0
# | Creation of neuron populations                                    |
# +-------------------------------------------------------------------+
# Neuron populations
pre_pop = sim.Population(pop_size, model, cell_params)
post_pop = sim.Population(pop_size, model, cell_params)


# Stimulating populations
pre_stim = sim.Population(pop_size, sim.SpikeSourceArray, {'spike_times': [[i for i in range(0, sim_time, time_between_pairs)],]})
post_stim = sim.Population(pop_size, sim.SpikeSourceArray, {'spike_times': [[i for i in range(pairing_start_time, pairing_end_time, time_between_pairs)],]})

# +-------------------------------------------------------------------+
# | Creation of connections                                           |
# +-------------------------------------------------------------------+
# Connection type between noise poisson generator and excitatory 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')

# Plastic Connections between pre_pop and post_pop
stdp_model = sim.STDPMechanism(
  timing_dependence = sim.SpikePairRule(tau_plus = 20.0, tau_minus = 50.0),
  weight_dependence = sim.AdditiveWeightDependence(w_min = 0.1, w_max = 1, A_plus=0.02, A_minus = 0.02)
)

prepostpro = sim.Projection(pre_pop, post_pop, sim.OneToOneConnector(weights=1.0), 
  synapse_dynamics = sim.SynapseDynamics(slow= stdp_model)
)

# Record spikes
コード例 #4
0
out1 = p.Projection(plus_detector,
                    output,
                    p.FromListConnector(
                        retina_lib.AllToOne(subsample_size * subsample_size,
                                            BWD, .25, 1)),
                    target='excitatory')
#check between forward and backwards and what will happen if left and right directions are given
out2 = p.Projection(cross_detector,
                    output,
                    p.FromListConnector(
                        retina_lib.AllToOne(subsample_size * subsample_size,
                                            FWD, .25, 1)),
                    target='excitatory')

inh_out_1 = p.Projection(output,
                         output,
                         p.AllToAllConnector(weights=-5,
                                             delays=1,
                                             allow_self_connections=False),
                         target='inhibitory')
robot_projections = p.Projection(output,
                                 robot_motor_control,
                                 p.OneToOneConnector(weights=-5, delays=1),
                                 target='excitatory')

#output.set_robotic_output()
#output1.set_mapping_constraint({'x':0,'y':0})

p.run(runtime)  # Simulation time
p.end()
コード例 #5
0
#!/usr/bin/python
import pacman103.front.pynn as p
import numpy, pylab

#set up pacman103
p.setup(timestep=1.0, min_delay=1.0, max_delay=32.0)

#external stuff population requiremenets
connected_chip_coords = {'x': 0, 'y': 0}
virtual_chip_coords = {'x': 0, 'y': 5}
link = 4

populations = list()
projections = list()

populations.append(p.Population(1, p.SpikeSourcePoisson, {'rate': 10000}))

populations.append(
    p.Population(1,
                 p.RobotMotorControl, {
                     'virtual_chip_coords': virtual_chip_coords,
                     'connected_chip_coords': connected_chip_coords,
                     'connected_chip_edge': link
                 },
                 label='External motor control'))

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

p.run(10000)
コード例 #6
0
delay_distr_recurrent = RandomDistribution('uniform', [2.0, 8.0], rng=rng)
weight_distr_ffwd = RandomDistribution('uniform', [0.5, 1.25], rng=rng)
weight_distr_recurrent = RandomDistribution('uniform', [0.1, 0.2], rng=rng)

projections.append(
    p.Projection(populations[stimulus],
                 populations[excit],
                 p.AllToAllConnector(weights=baseline_excit_weight,
                                     delays=1.0),
                 target='excitatory',
                 synapse_dynamics=p.SynapseDynamics(slow=stdp_model)))

projections.append(
    p.Projection(populations[teacher],
                 populations[excit],
                 p.OneToOneConnector(weights=weight_to_force_firing,
                                     delays=1.0),
                 target='excitatory'))
#projections.append(p.Projection(populations[stimulus], populations[inhib], p.FixedProbabilityConnector(p_connect=p_exc2inh, weights=baseline_excit_weight, delays=inh_delay_distr), target='excitatory'))

populations[stimulus].record(visualiser_mode=modes.RASTER)

#populations[inhib].record_v()
#populations[inhib].record(visualiser_mode=modes.RASTER)

populations[excit].record_v()
populations[excit].record(visualiser_mode=modes.RASTER)

populations[teacher].record(visualiser_mode=modes.RASTER)

#populations[noise].record_v()
#populations[noise].record(visualiser_mode=modes.RASTER)
コード例 #7
0
    ]})
post_stim = sim.Population(
    pop_size, sim.SpikeSourceArray, {
        'spike_times': [
            [
                i for i in range(pairing_start_time, pairing_end_time,
                                 time_between_pairs)
            ],
        ]
    })

# +-------------------------------------------------------------------+
# | Creation of connections                                           |
# +-------------------------------------------------------------------+
# Connection type between noise poisson generator and excitatory 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')

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

sim.Projection(pre_pop,
               post_pop,
               sim.OneToOneConnector(),
コード例 #8
0
                'tau_refrac'   : 100, 
                'i_offset'   : 1
                }

cell_params_lif = { 'tau_m'      : 32,
                'cm'        : 0.35,     # added to make PACMAN103 work
                'v_init'    : -80,
                'v_rest'     : -70,   
                'v_reset'    : -95,  
                'v_thresh'   : -55,
                'tau_syn_E'   : 5,
                'tau_syn_I'   : 10,
                'tau_refrac'   : 5,                 
                'i_offset'   : 0
                }

populations = list()
projections = list()

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

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

projections.append(p.Projection(populations[0], populations[1], p.OneToOneConnector(weights=8, delays=16)))

populations[0].set_mapping_constraint({'x':7, 'y':7})
populations[1].set_mapping_constraint({'x':3, 'y':4})

p.run(3000)