Deep Learning Tools/Nengo
많은 neuron으로 sine wave 표현하기
바나나인간
2018. 11. 5. 11:28
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | import numpy as np import matplotlib.pyplot as plt %matplotlib inline import nengo from nengo.dists import Uniform model = nengo.Network(label='Many Neurons') with model: A = nengo.Ensemble(100, dimensions=1) sin = nengo.Node(lambda t: np.sin(8 * t)) nengo.Connection(sin, A, synapse=0.01) sin_probe = nengo.Probe(sin) A_probe = nengo.Probe(A, synapse=0.01) # 10ms filter A_spikes = nengo.Probe(A.neurons) with nengo.Simulator(model) as sim: sim.run(1) from nengo.utils.matplotlib import rasterplot # Plot the decoded output of the ensemble plt.figure() plt.plot(sim.trange(), sim.data[A_probe], label="A output") plt.plot(sim.trange(), sim.data[sin_probe], 'r', label="Input") plt.xlim(0, 1) plt.legend() # Plot the spiking output of the ensemble plt.figure() rasterplot(sim.trange(), sim.data[A_spikes]) plt.xlim(0, 1); | cs |