Example #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)