def test_network(): neurons = {0: IFNeuron(5), 1: IFNeuron(10), 2: IFNeuron(20)} inputs = [0, 1] outputs = [2] connections = [(0, 2, 0.123), (1, 2, 0.234)] net = IFNetwork(neurons, inputs, outputs, connections)
from __future__ import print_function import matplotlib.pyplot as plt from neatsociety.ifnn import IFNeuron n = IFNeuron() times = [] currents = [] potentials = [] fired = [] for i in range(1000): times.append(1.0 * i) n.current = 0.0 if i < 100 or i > 800 else 16.0 currents.append(n.current) n.advance() potentials.append(n.potential) fired.append(1.0 if n.has_fired else 0.0) plt.subplot(3, 1, 1) plt.title("IFNN model") plt.ylabel("Input current") plt.ylim(0, 20) plt.grid() plt.plot(times, currents, "b-", label="current") plt.subplot(3, 1, 2) plt.ylabel("Potential")
def test_basic(): n = IFNeuron(20) spike_train = [] for i in range(1000): spike_train.append(n.potential) n.advance()