本文整理汇总了Python中pyNN.spiNNaker.end函数的典型用法代码示例。如果您正苦于以下问题:Python end函数的具体用法?Python end怎么用?Python end使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了end函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
def main():
# setup timestep of simulation and minimum and maximum synaptic delays
setup(timestep=simulationTimestep, min_delay=minSynapseDelay, max_delay=maxSynapseDelay, threads=4)
# 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
plotExperiment(retinaLeft, retinaRight, network)
# finalise program and simulation
end()
示例2: end
def end():
spynnaker.end()
示例3: len
pylab.title('spikes')
pylab.show()
else:
print "No spikes received"
# Make some graphs
if v is not None:
ticks = len(v) / nNeurons
pylab.figure()
pylab.xlabel('Time/ms')
pylab.ylabel('v')
pylab.title('v')
for pos in range(0, nNeurons, 20):
v_for_neuron = v[pos * ticks: (pos + 1) * ticks]
pylab.plot([i[2] for i in v_for_neuron])
pylab.show()
if gsyn is not None:
ticks = len(gsyn) / nNeurons
pylab.figure()
pylab.xlabel('Time/ms')
pylab.ylabel('gsyn')
pylab.title('gsyn')
for pos in range(0, nNeurons, 20):
gsyn_for_neuron = gsyn[pos * ticks: (pos + 1) * ticks]
pylab.plot([i[2] for i in gsyn_for_neuron])
pylab.show()
p.end()
示例4: list
fast_injector.set("spike_times", [fast_spikes] + [[]] * 9)
if last_spike_slow < total_run_time + time_to_run:
slow_spikes = list(islice(slow_spike_iter, 10))
last_spike_slow = slow_spikes[-1]
slow_injector.set("spike_times", [slow_spikes] + [[]] * 9)
sim.run(time_to_run)
total_run_time += time_to_run
plt.xlim(max(0, total_run_time - 5*time_to_run), total_run_time)
if mode == "spikes":
plt.ylim(-1, 101)
all_spikes = populations[-1].getSpikes()
print "Total spikes %d" % len(all_spikes)
spikes = list(takewhile(lambda x: x[1] > total_run_time - time_to_run, all_spikes))
plt.plot([i[1] for i in spikes], [i[0] for i in spikes], ".", markersize=2)
else:
plt.ylim(v_reset - 5, v_thresh + 5)
voltages = list(ifilter(lambda x: x[0] == 1 and x[1] >= total_run_time - time_to_run,
reversed(populations[0].get_v())))
plt.plot([i[1] for i in voltages], [i[2] for i in voltages], "b-", markersize=1)
plt.draw()
plt.pause(0.001)
if not plt.get_fignums():
running = False
sim.end()
示例5: len
n = n % len(seq)
return seq[n:] + seq[:n]
# connect all populations, but don't close the chain
for pop_a, pop_b in zip(all_pops, shift(all_pops, 1)[:-1]):
pynn.Projection(pop_a, pop_b, con_fixednumberpre, target='excitatory')
pynn.run(duration)
spikes = None
# Collect and record spikes
for pop in all_pops:
new_spikes = pop.getSpikes(compatible_output=True)
if new_spikes is not None:
numpy.fliplr(new_spikes)
new_spikes = new_spikes / [1, 1000.0]
if spikes is None:
spikes = new_spikes
else:
new_spikes = new_spikes + [len(spikes), 0]
spikes = numpy.concatenate((spikes, new_spikes), axis=0)
if spikes is None:
spikes = []
print "N spikes", len(spikes)
numpy.savetxt("spikes.dat", spikes)
pynn.end()
示例6: run_sim
def run_sim(self):
"""
Sets up and runs the simulation
"""
num_neurons = 1471 # total neurons in network
num_inputs = 14 # number of neurons considered inputs
num_runs = 1 # number of times to loop the learning
num_samples = 1 # number of samples to learn`
sim_time = 1000.0 # time to run sim for`
inhibitory_split = 0.2
connection_probability_factor = 0.02
plot_spikes = True
save_figures = True
show_figures = True
sim_start_time = strftime("%Y-%m-%d_%H:%M")
cell_params_lif = {'cm': 0.25, 'i_offset': 0.0, 'tau_m': 10.0, 'tau_refrac': 2.0, 'tau_syn_E': 3.0,
'tau_syn_I': 3.0, 'v_reset': -65.0, 'v_rest': -65.0, 'v_thresh': -50.0}
# Create the 3d structure of the NeuCube based on the user's given structure file
network_structure = NetworkStructure()
network_structure.load_structure_file()
network_structure.load_input_location_file()
# Calculate the inter-neuron distance to be used in the small world connections
network_structure.calculate_distances()
# Generate two connection matrices for excitatory and inhibitory neurons based on your defined split
network_structure.calculate_connection_matrix(inhibitory_split, connection_probability_factor)
# Get these lists to be used when connecting the neurons later
excitatory_connection_list = network_structure.get_excitatory_connection_list()
inhibitory_connection_list = network_structure.get_inhibitory_connection_list()
# Choose the correct neurons to connect them to, based on your a-priori knowledge of the data source -- eg, EEG
# to 10-20 locations, fMRI to voxel locations, etc.
input_neuron_indexes = network_structure.find_input_neurons()
# Make the input connections based on this new list
input_weight = 4.0
input_connection_list = []
for index, input_neuron_index in enumerate(input_neuron_indexes):
input_connection_list.append((index, input_neuron_index, input_weight, 0))
for run_number in xrange(num_runs):
excitatory_weights = []
inhibitory_weights = []
for sample_number in xrange(num_samples):
# At the moment with the limitations of the SpiNNaker hardware we have to reinstantiate EVERYTHING
# each run. In future there will be some form of repetition added, where the structure stays in memory
# on the SpiNNaker and only the input spikes need to be updated.
data_prefix = sim_start_time + "_r" + str(run_number + 1) + "-s" + str(sample_number + 1)
# Set up the hardware - min_delay should never be less than the timestep.
# Timestep should = 1.0 (ms) for normal realtime applications
p.setup(timestep=1.0, min_delay=1.0)
p.set_number_of_neurons_per_core("IF_curr_exp", 100)
# Create a population of neurons for the reservoir
neurons = p.Population(num_neurons, p.IF_curr_exp, cell_params_lif, label="Reservoir")
# Setup excitatory STDP
timing_rule_ex = p.SpikePairRule(tau_plus=20.0, tau_minus=20.0)
weight_rule_ex = p.AdditiveWeightDependence(w_min=0.1, w_max=1.0, A_plus=0.02, A_minus=0.02)
stdp_model_ex = p.STDPMechanism(timing_dependence=timing_rule_ex, weight_dependence=weight_rule_ex)
# Setup inhibitory STDP
timing_rule_inh = p.SpikePairRule(tau_plus=20.0, tau_minus=20.0)
weight_rule_inh = p.AdditiveWeightDependence(w_min=0.0, w_max=0.6, A_plus=0.02, A_minus=0.02)
stdp_model_inh = p.STDPMechanism(timing_dependence=timing_rule_inh, weight_dependence=weight_rule_inh)
# record the spikes from that population
neurons.record('spikes')
# Generate a population of SpikeSourceArrays containing the encoded input spike data
# eg. spike_sources = p.Population(14, p.SpikeSourceArray, {'spike_times': [[]]})
# for the moment I'm going to cheat and just use poisson trains as I don't have data with me
spike_sources = p.Population(num_inputs, p.SpikeSourcePoisson, {'rate': rand.randint(20, 80)},
label="Poisson_pop_E")
# Connect the input spike sources with the "input" neurons
connected_inputs = p.Projection(spike_sources, neurons, p.FromListConnector(input_connection_list))
# If we have weights saved/recorded from a previous run of this network, load them into the structure
# population.set(weights=weights_list) and population.setWeights(weight_list) are not supported in
# SpiNNaker at the moment so we have to do this manually.
if excitatory_weights and inhibitory_weights:
for index, ex_connection in enumerate(excitatory_connection_list):
ex_connection[2] = excitatory_weights[index]
for index, in_connection in enumerate(inhibitory_connection_list):
in_connection[2] = inhibitory_weights[index]
# Setup the connectors
excitatory_connector = p.FromListConnector(excitatory_connection_list)
inhibitory_connector = p.FromListConnector(inhibitory_connection_list)
# Connect the excitatory and inhibitory neuron populations
connected_excitatory_neurons = p.Projection(neurons, neurons, excitatory_connector,
synapse_dynamics=p.SynapseDynamics(slow=stdp_model_ex),
target="excitatory")
connected_inhibitory_neurons = p.Projection(neurons, neurons, inhibitory_connector,
synapse_dynamics=p.SynapseDynamics(slow=stdp_model_inh),
target="inhibitory")
# Set up recording the spike trains of all the neurons
#.........这里部分代码省略.........