Ejemplo n.º 1
0
def test_basic():
    # create two output neurons (they won't receive any external inputs)
    n1 = CTNeuron('OUTPUT', 1, -2.75, 1.0, 'sigmoid', 0.5)
    n1.set_integration_step(0.04)
    repr(n1)
    str(n1)
    n2 = CTNeuron('OUTPUT', 2, -1.75, 1.0, 'sigmoid', 0.5)
    n2.set_integration_step(0.04)
    repr(n2)
    str(n2)
    n1.set_init_state(-0.084000643)
    n2.set_init_state(-0.408035109)

    neurons_list = [n1, n2]
    # create some synapses
    conn_list = [(1, 1, 4.5), (1, 2, -1.0), (2, 1, 1.0), (2, 2, 4.5)]
    # create the network
    net = Network(neurons_list, conn_list, 0)
    net.set_integration_step(0.03)
    repr(net)
    str(net)
    # activates the network
    print("{0:.7f} {1:.7f}".format(n1.output, n2.output))
    outputs = []
    for i in range(1000):
        output = net.parallel_activate()
        outputs.append(output)
        print("{0:.7f} {1:.7f}".format(output[0], output[1]))

    for s in net.synapses:
        repr(s)
        str(s)
Ejemplo n.º 2
0
def create_simple():
    neurons = [Neuron('INPUT', 1, 0.0, 5.0, 'sigmoid'),
               Neuron('HIDDEN', 2, 0.0, 5.0, 'sigmoid'),
               Neuron('OUTPUT', 3, 0.0, 5.0, 'sigmoid')]
    connections = [(1, 2, 0.5), (1, 3, 0.5), (2, 3, 0.5)]
    map(repr, neurons)

    return Network(neurons, connections, 1)
Ejemplo n.º 3
0
def test_basic():
    # create two output neurons (they won't receive any external inputs)
    n1 = CTNeuron('OUTPUT', 1, -2.75, 1.0, 'exp', 0.5)
    n2 = CTNeuron('OUTPUT', 2, -1.75, 1.0, 'exp', 0.5)
    n1.set_init_state(-0.084000643)
    n2.set_init_state(-0.408035109)

    neurons_list = [n1, n2]
    # create some synapses
    conn_list = [(1, 1, 4.5), (1, 2, -1.0), (2, 1, 1.0), (2, 2, 4.5)]
    # create the network
    net = Network(neurons_list, conn_list)
    # activates the network
    print("%.17f %.17f" % (n1.output, n2.output))
    outputs = []
    for i in range(1000):
        output = net.parallel_activate()
        outputs.append(output)
        print("%.17f %.17f" % (output[0], output[1]))
Ejemplo n.º 4
0
import numpy as np
import matplotlib.pyplot as plt

from neat.ctrnn import CTNeuron, Network

# create two output neurons (they won't receive any external inputs)
N1 = CTNeuron('OUTPUT', 1, -2.75, 1.0, 'exp', 0.5)
N2 = CTNeuron('OUTPUT', 2, -1.75, 1.0, 'exp', 0.5)
N1.set_init_state(-0.084000643)
N2.set_init_state(-0.408035109)

neurons_list = [N1, N2]
# create some synapses
conn_list = [(1, 1, 4.5), (1, 2, -1.0), (2, 1, 1.0), (2, 2, 4.5)]
# create the network
net = Network(neurons_list, conn_list)
# activates the network
print("%.17f %.17f" % (N1.output, N2.output))
outputs = []
for i in range(1000):
    output = net.parallel_activate()
    outputs.append(output)
    print("%.17f %.17f" % (output[0], output[1]))

outputs = np.array(outputs).T

plt.title("CTRNN model")
plt.ylabel("Outputs")
plt.xlabel("Time")
plt.grid()
plt.plot(outputs[0], "g-", label="output 0")
import numpy as np
import matplotlib.pyplot as plt

from neat.ctrnn import CTNeuron, Network

# create two output neurons (they won't receive any external inputs)
N1 = CTNeuron('OUTPUT', 1, -2.75, 1.0, 'sigmoid', 0.5)
N2 = CTNeuron('OUTPUT', 2, -1.75, 1.0, 'sigmoid', 0.5)
N1.set_init_state(-0.084000643)
N2.set_init_state(-0.408035109)

neurons_list = [N1, N2]
# create some synapses
conn_list = [(1, 1, 4.5), (1, 2, -1.0), (2, 1, 1.0), (2, 2, 4.5)]
# create the network
net = Network(neurons_list, conn_list, 0)
# activates the network
print("{0:.7f} {1:.7f}".format(N1.output, N2.output))
outputs = []
for i in range(1000):
    output = net.parallel_activate()
    outputs.append(output)
    print("{0:.7f} {1:.7f}".format(output[0], output[1]))

outputs = np.array(outputs).T

plt.title("CTRNN model")
plt.ylabel("Outputs")
plt.xlabel("Time")
plt.grid()
plt.plot(outputs[0], "g-", label="output 0")