当前位置: 首页>>代码示例>>Python>>正文


Python nest.setup函数代码示例

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


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

示例1: run_test

def run_test(w_list, cell_para, spike_source_data):
    pop_list = []
    p.setup(timestep=1.0, min_delay=1.0, max_delay=3.0)
    #input poisson layer
    input_size = w_list[0].shape[0]
    pop_in = p.Population(input_size, p.SpikeSourceArray, {'spike_times' : []})
    for j in range(input_size):
        pop_in[j].spike_times = spike_source_data[j]
    pop_list.append(pop_in)
    
    for w in w_list:        
        pos_w = np.copy(w)
        pos_w[pos_w < 0] = 0
        neg_w = np.copy(w)
        neg_w[neg_w > 0] = 0
        
        output_size = w.shape[1]
        pop_out = p.Population(output_size, p.IF_curr_exp, cell_para)
        p.Projection(pop_in, pop_out, p.AllToAllConnector(weights = pos_w), target='excitatory')
        p.Projection(pop_in, pop_out, p.AllToAllConnector(weights = neg_w), target='inhibitory')
        pop_list.append(pop_out)
        pop_in = pop_out

    pop_out.record()
    run_time = np.ceil(np.max(spike_source_data)[0]/1000.)*1000
    p.run(run_time)
    spikes = pop_out.getSpikes(compatible_output=True)
    return spikes
开发者ID:qian-liu,项目名称:iconip2016,代码行数:28,代码来源:spiking_relu.py

示例2: sim_neuron

def sim_neuron(rate):
	neuron_parameters={
            'v_rest'     : -50.0,
            'cm'         : 1,
            'tau_m'      : 20.0,
            'tau_syn_E'  : 5.0,
            'tau_syn_I'  : 5.0,
            'v_reset'    : -50.0,
            'v_thresh'   : 10000000000000000000000000000000000000000000000000000000000000000000000.0,
            'e_rev_E'	 : 0.0,
            'e_rev_I'	 : -100,
	}
	time_simulation = 100000 # don't choose to small number in order to get good statistics
	weight = 0.1 # is this value allreight
	sim.setup(timestep=0.1, min_delay=0.1)
	
	pois_exc = sim.SpikeSourcePoisson(duration=time_simulation,start=0.0,rate=rate) # generate poisson rate stimulus
	pois_inh = sim.SpikeSourcePoisson(duration=time_simulation,start=0.0,rate=rate) # generate poisson rate stimulus
	exc = sim.Population(1, cellclass=pois_exc) # simulate excitatory cell
	inh = sim.Population(1, cellclass=pois_inh) # simulate inhibitory cell
	
	rec = sim.Population(1, sim.IF_cond_exp(**neuron_parameters)) # simulate receiving neuron

	sim.Projection(exc, rec, connector=sim.OneToOneConnector(),synapse_type=sim.StaticSynapse(weight=weight),receptor_type='excitatory') # connect excitatory neuron to receiver
	sim.Projection(inh, rec, connector=sim.OneToOneConnector(),synapse_type=sim.StaticSynapse(weight=weight),receptor_type='inhibitory') # connect inhibitory neuron to receiver

	rec.record('v') # record membrane potential
	rec.record('gsyn_exc') # record excitatory conductance
	rec.record('gsyn_inh') # record inhibitory conductance
	sim.run(time_simulation) # start simulation

	return rec.get_data('v').segments[0].analogsignalarrays[0], rec.get_data('gsyn_exc').segments[0].analogsignalarrays[0], rec.get_data('gsyn_inh').segments[0].analogsignalarrays[0] # return membrane potential, excitatory conductance, inhibitory conductance
开发者ID:knly,项目名称:bic-ws1516,代码行数:32,代码来源:exercise1.py

示例3: two_neuron_example

def two_neuron_example(
    current=1000.0,
    time_simulation=2000.0,
    weight=0.4,
    neuron_parameters={"v_rest": -50.0, "cm": 1, "tau_m": 20.0, "tau_refrac": 5.0, "v_thresh": -40.0, "v_reset": -50.0},
):

    sim.setup(timestep=0.1, min_delay=0.1)

    pulse = sim.DCSource(amplitude=current, start=0.0, stop=time_simulation)

    pre = sim.Population(1, sim.IF_curr_exp(**neuron_parameters))

    pre.record("spikes")

    pulse.inject_into(pre)

    sim.run(time_simulation)

    # rates in Hz
    rate_pre = len(pre.get_data("spikes").segments[0].spiketrains[0]) / time_simulation * 1000.0

    sim.end()

    return rate_pre
开发者ID:knly,项目名称:bic-ws1516,代码行数:25,代码来源:exercise2.py

示例4: main

def main(args):

    setup(timestep=0.1)

    random_image = np.random.rand(2,2)
    size = random_image.size


    input_population_arr = Population(random_image.size, SpikeSourceArray, {'spike_times': [0 for i in range(0, random_image.size)]})

    cell_params = {'tau_refrac': 2.0, 'v_thresh': -50.0, 'tau_syn_E': 2.0, 'tau_syn_I': 2.0}
    output_population = Population(1, IF_curr_alpha, cell_params, label="output")

    projection = Projection(input_population_arr, output_population, AllToAllConnector())
    projection.setWeights(1.0)

    input_population_arr.record('spikes')
    output_population.record('spikes')

    tstop = 1000.0

    run(tstop)

    output_population.write_data("simpleNetwork_output.pkl",'spikes')
    input_population_arr.write_data("simpleNetwork_input.pkl",'spikes')
    #output_population.print_v("simpleNetwork.v")
    end()
开发者ID:danielgeier,项目名称:ml2-spiking,代码行数:27,代码来源:population_example.py

示例5: main

def main():
    # setup timestep of simulation and minimum and maximum synaptic delays
    setup(timestep=simulationTimestep, min_delay=minSynapseDelay, max_delay=maxSynapseDelay)
    
    # create a spike sources
    retinaLeft = createSpikeSource("Retina Left")
    retinaRight = createSpikeSource("Retina Right")
    
    # create network and attach the spike sources 
    network = createCooperativeNetwork(retinaLeft=retinaLeft, retinaRight=retinaRight)
    
    # run simulation for time in milliseconds
    print "Simulation started..."
    run(simulationTime)
    print "Simulation ended."
    # plot results 
    from itertools import repeat
    numberOfLayersToPlot = 4
    layers = zip(repeat(network, numberOfLayersToPlot), range(1, numberOfLayersToPlot+1), repeat(False, numberOfLayersToPlot))
    customLayers = [(network, 20, False),(network, 40, False),(network, 60, False),(network, 80, False)]
    for proc in range(0, numberOfLayersToPlot):
        p = Process(target=plotSimulationResults, args=customLayers[proc])
        p.start()
    
    # finalise program and simulation
    end()
开发者ID:AMFtech,项目名称:StereoMatching,代码行数:26,代码来源:CooperativeNetwork.py

示例6: setUp

 def setUp(self):
     sim.setup()
     self.p1 = sim.Population(7, sim.IF_cond_exp())
     self.p2 = sim.Population(4, sim.IF_cond_exp())
     self.p3 = sim.Population(5, sim.IF_curr_alpha())
     self.syn_rnd = sim.StaticSynapse(weight=0.123, delay=0.5)
     self.syn_a2a = sim.StaticSynapse(weight=0.456, delay=0.4)
     self.random_connect = sim.FixedNumberPostConnector(n=2)
     self.all2all = sim.AllToAllConnector()
开发者ID:jakobj,项目名称:PyNN,代码行数:9,代码来源:test_nest.py

示例7: test_ticket240

def test_ticket240():
    nest = pyNN.nest
    nest.setup(threads=4)
    parameters = {'Tau_m': 17.0}
    p1 = nest.Population(4, nest.IF_curr_exp())
    p2 = nest.Population(5, nest.native_cell_type("ht_neuron")(**parameters))
    conn = nest.AllToAllConnector()
    syn = nest.StaticSynapse(weight=1.0)
    prj = nest.Projection(p1, p2, conn, syn, receptor_type='AMPA') # This should be a nonstandard receptor type but I don't know of one to use.
    connections = prj.get(('weight',), format='list')
    assert len(connections) > 0
开发者ID:mfraezz,项目名称:PyNN,代码行数:11,代码来源:test_nest.py

示例8: test_ticket244

def test_ticket244():
    nest = pyNN.nest
    nest.setup(threads=4)
    p1 = nest.Population(4, nest.IF_curr_exp())
    p1.record('spikes')
    poisson_generator = nest.Population(3, nest.SpikeSourcePoisson(rate=1000.0))
    conn = nest.OneToOneConnector()
    syn = nest.StaticSynapse(weight=1.0)
    nest.Projection(poisson_generator, p1.sample(3), conn, syn, receptor_type="excitatory")
    nest.run(15)
    p1.get_data()
开发者ID:mfraezz,项目名称:PyNN,代码行数:11,代码来源:test_nest.py

示例9: two_neuron_example

def two_neuron_example(
        current=1000.0,
        time_simulation=2000.,
        weight=0.4,
        neuron_parameters={
            'v_rest'     : -65.0,
            'cm'         : 0.1,
            'tau_m'      : 1.0,
            'tau_refrac' : 2.0,
            'tau_syn_E'  : 10.0,
            'tau_syn_I'  : 10.0,
            'i_offset'   : 0.0,
            'v_reset'    : -65.0,
            'v_thresh'   : -50.0,
        },
    ):
    """
        Connects to neurons with corresponding parameters.

        The first is stimulated via current injection while the second receives
        the other one's spikes.
    """

    sim.setup(timestep=0.1, min_delay=0.1)

    pulse = sim.DCSource(amplitude=current, start=0.0, stop=time_simulation)

    pre = sim.Population(1, sim.IF_curr_exp(**neuron_parameters))
    post = sim.Population(1, sim.IF_curr_exp(**neuron_parameters))

    pre.record('spikes')
    post.record('spikes')

    sim.Projection(pre, post, connector=sim.OneToOneConnector(),
            synapse_type=sim.StaticSynapse(weight=weight),
            receptor_type='excitatory')

    pulse.inject_into(pre)

    sim.run(time_simulation)

    # rates in Hz
    rate_pre = len(pre.get_data('spikes').segments[0].spiketrains[0])\
            / time_simulation * 1000.

    rate_post = len(post.get_data('spikes').segments[0].spiketrains[0])\
            / time_simulation * 1000.

    sim.end()

    return rate_pre, rate_post
开发者ID:knly,项目名称:bic-ws1516,代码行数:51,代码来源:bic_sh01_ex03_code.py

示例10: __init__

  def __init__(self, N, cell_params,col_params,sim_params, graph=None, le=1., li=1., velocity=None):
    self.mpi_print("Creation of the layer ...")
    self.velocity = velocity
    self.scaling  = 0.06 # width, in mm, of one column
    self.timestep=sim_params['dt']
    if velocity is None:
      max_delay = self.timestep
    else:      
      max_delay    = numpy.sqrt(2)*N*self.scaling/self.velocity
    self.mpi_print("Timestep is %g ms, max delay has been set to %g ms" %(self.timestep, max_delay))

    self.node_id    = sim.setup(self.timestep, max_delay=max_delay)
    self.N          = N
    self.blocs      = numpy.array([Column(cell_params,col_params) for i in xrange(N**2)])
    self.blocs      = self.blocs.reshape(N,N)
    self.recordings = []
    self.le         = le
    self.li         = li
    self.w_E        = self.blocs[0,0].w_E
    self.w_I        = self.blocs[0,0].w_I
    self.Ne         = len(self.blocs[0,0].exc)
    self.Ni         = len(self.blocs[0,0].inh)
    self.graph=graph
    if self.graph!=None: self.conn_graph = cg.OneColGraph(self.graph)
    self.mpi_print("A layer of size %d x %d x %d = %d cells has been built" %(self.N, self.N, self.Ne+self.Ni, (self.Ne+self.Ni) * self.N**2))
    self.conn_graph.make_layer_nodes(
                range(self.get_exc_from_blocks(self.graph).first_id,self.get_exc_from_blocks(self.graph).last_id+1)
              , range(self.get_inh_from_blocks(self.graph).first_id,self.get_inh_from_blocks(self.graph).last_id+1)
              )
开发者ID:colliauXD,项目名称:PyCB,代码行数:29,代码来源:col_diag.py

示例11: main

def main(argv):
    rospy.init_node('SNN', disable_signals=True)
    nest.setup(timestep=TIME_STEP)

    parser = create_argument_parser()
    n = parser.parse_args()

    #world = World()

    #network, actor_network, braitenberg = NetworkBuilder.braitenberg_deep_network(number_middle_layers=1, number_neurons_per_layer=5, image_topic='/spiky/retina_image')
    #network, actor_network = NetworkBuilder.braitenberg_network(image_topic='/spiky/binary_image')

    network, actor_network, braitenberg = NetworkBuilder.braitenberg_deep_network_parallel(number_middle_layers=1, number_neurons_per_layer=5)

    world = BraitenbergSupervisedWorld(braitenberg)

    learner = ReinforcementLearner(network, world, BETA_SIGMA, SIGMA, TAU, NUM_TRACE_STEPS, 2,
                                   DISCOUNT_FACTOR, TIME_STEP, LEARNING_RATE)

    agent = SnnAgent(timestep=TIME_STEP, simduration=5, learner=learner, should_learn=True, network=network,
                     actor_network=actor_network)

    n.plot = False
    if n.plot:
        plotter = NetworkPlotter(agent, plot_steps=20)

    n.log = True
    if n.log:
        logger = NetworkLogger(agent, network, log_period=60)

    n.cockpit = True
    if n.cockpit:
        cockpit_view = cockpit.CockpitViewModel(network, agent)

    while True:
        # Inject frame to network and start simulation
        agent.step()

        if n.plot:
            plotter.update()

        if n.log:
            logger.log()

        if n.cockpit:
            cockpit_view.update()
开发者ID:danielgeier,项目名称:ml2-spiking,代码行数:46,代码来源:neuralnet.py

示例12: ready

    def ready(self):
        sim.setup(timestep=1.)

        # set up spike sources
        self.spike_source = sim.Population(self.n_spike_source, sim.SpikeSourceArray(), label='spike sources')
        # set up hidden neurons
        self.hidden_neurons = sim.Population(self.n_hidden_neurons, self.cell_type(**self.parameters), label='hidden neurons')
        # set up output neurons
        self.output_neurons = sim.Population(self.n_output_neurons, self.cell_type_out(**self.parameters_out), label='output neurons')
        self.output_neurons.set(I_e=1.0, V_th=1500.0) ## new new new

        # build connections
        self.connection_in = sim.Projection(self.spike_source, self.hidden_neurons, sim.FromListConnector(self.connection_in_list))
        self.connection_hidden = sim.Projection(self.hidden_neurons, self.hidden_neurons, sim.FromListConnector(self.connection_hidden_list))
        self.connection_out = sim.Projection(self.hidden_neurons, self.output_neurons, sim.FromListConnector(self.connection_out_list))

        self.output_neurons.record('spikes')
        self.hidden_neurons.record('spikes')
开发者ID:starlitnext,项目名称:SpikingRNN,代码行数:18,代码来源:rsnn_sim_int.py

示例13: test_native_stdp_model

def test_native_stdp_model():
    nest = pyNN.nest
    from pyNN.utility import init_logging

    init_logging(logfile=None, debug=True)

    nest.setup()

    p1 = nest.Population(10, nest.IF_cond_exp())
    p2 = nest.Population(10, nest.SpikeSourcePoisson())

    stdp_params = {'Wmax': 50.0, 'lambda': 0.015, 'weight': 0.001}
    stdp = nest.native_synapse_type("stdp_synapse")(**stdp_params)

    connector = nest.AllToAllConnector()

    prj = nest.Projection(p2, p1, connector, receptor_type='excitatory',
                          synapse_type=stdp)
开发者ID:mfraezz,项目名称:PyNN,代码行数:18,代码来源:test_nest.py

示例14: test_native_stdp_model

def test_native_stdp_model():
    nest = pyNN.nest
    from pyNN.utility import init_logging

    init_logging(logfile=None, debug=True)
    
    nest.setup()
    
    p1 = nest.Population(10, nest.IF_cond_exp)
    p2 = nest.Population(10, nest.SpikeSourcePoisson)
    
    stdp_params = {'Wmax': 50.0, 'lambda': 0.015}
    stdp = nest.NativeSynapseDynamics("stdp_synapse", stdp_params)
    
    connector = nest.AllToAllConnector(weights=0.001)
    
    prj = nest.Projection(p2, p1, connector, target='excitatory',
                          synapse_dynamics=stdp)
开发者ID:agravier,项目名称:pynn,代码行数:18,代码来源:test_nest.py

示例15: test_record_native_model

def test_record_native_model():
    if not have_nest:
        raise SkipTest
    nest = pyNN.nest
    from pyNN.random import RandomDistribution

    init_logging(logfile=None, debug=True)

    nest.setup()

    parameters = {'tau_m': 17.0}
    n_cells = 10
    p1 = nest.Population(n_cells, nest.native_cell_type("ht_neuron")(**parameters))
    p1.initialize(V_m=-70.0, Theta=-50.0)
    p1.set(theta_eq=-51.5)
    #assert_arrays_equal(p1.get('theta_eq'), -51.5*numpy.ones((10,)))
    assert_equal(p1.get('theta_eq'), -51.5)
    print(p1.get('tau_m'))
    p1.set(tau_m=RandomDistribution('uniform', low=15.0, high=20.0))
    print(p1.get('tau_m'))

    current_source = nest.StepCurrentSource(times=[50.0, 110.0, 150.0, 210.0],
                                            amplitudes=[0.01, 0.02, -0.02, 0.01])
    p1.inject(current_source)

    p2 = nest.Population(1, nest.native_cell_type("poisson_generator")(rate=200.0))

    print("Setting up recording")
    p2.record('spikes')
    p1.record('V_m')

    connector = nest.AllToAllConnector()
    syn = nest.StaticSynapse(weight=0.001)

    prj_ampa = nest.Projection(p2, p1, connector, syn, receptor_type='AMPA')

    tstop = 250.0
    nest.run(tstop)

    vm = p1.get_data().segments[0].analogsignals[0]
    n_points = int(tstop / nest.get_time_step()) + 1
    assert_equal(vm.shape, (n_points, n_cells))
    assert vm.max() > 0.0  # should have some spikes
开发者ID:antolikjan,项目名称:PyNN,代码行数:43,代码来源:test_nest.py


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