Exemplo 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)
Exemplo n.º 2
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 = nn.Network(neurons_list, conn_list)
    # activates the network
    print "%.17f %.17f" % (N1.output, N2.output)
    outputs = []
    for i in xrange(1000):
        output = net.pactivate()
        outputs.append(output)
        print "%.17f %.17f" % (output[0], output[1])
Exemplo 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]))
# This example follows from Beer's C++ source code available at:
# http://mypage.iu.edu/~rdbeer/
from __future__ import print_function
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")
# This example follows from Beer's C++ source code available at:
# http://mypage.iu.edu/~rdbeer/
from __future__ import print_function
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")