Exemplo n.º 1
0
def var_4():
    n1 = n([-1], 0, linear_activation_double)
    n2 = n([0.2], 0, one_to_one_activation)
    n3 = n([0.2], 0, one_to_one_activation)
    n4 = n([2, -1.5], 0, linear_activation_double)

    def f(i):
        r1 = n1.calc([i], log=True)
        r2 = n2.calc([r1], log=True)
        r3 = n3.calc([r1], log=True)
        r4 = n4.calc([r2, r3], log=True)
        return r4

    def plot(dots):
        import matplotlib.pyplot as plt
        results = [f(dot) for dot in dots]
        fig = plt.figure()
        plt.plot(dots, results, 'ro')
        fig.suptitle('Task 5, Var 4', fontsize=20)
        plt.grid(True)
        plt.show()

    # print(f(0.5))
    import numpy as np
    plot(np.arange(-10., 10., 0.05))
Exemplo n.º 2
0
def var_3():
    n1 = n([2], 0.5, modular_activation)
    n2 = n([2], 0.5, modular_activation)
    n3 = n([1, -0.5], 0.5, linear_activation_double_plus_one)
    n4 = n([1, -0.5], 0.5, linear_activation_double_plus_one)

    def f(i):
        r1 = n1.calc([i], log=True)
        r2 = n2.calc([i], log=True)
        r3 = n3.calc([r1, r2], log=True)
        r4 = n4.calc([r1, r2], log=True)
        return r3, r4

    def plot(dots):
        import matplotlib.pyplot as plt
        results = [f(dot)[0] for dot in dots]
        fig = plt.figure()
        plt.plot(dots, results, 'ro')
        fig.suptitle('Task 5, Var 3', fontsize=20)
        plt.grid(True)
        plt.show()

    # print(f(-1.5))
    import numpy as np
    plot(np.arange(-10., 10., 0.05))
Exemplo n.º 3
0
def var_3():
    n1 = n([1, -1, 0, 0], -0.5)
    n2 = n([-1, 0, 0, 1], -0.5)
    n3 = n([1, 1], 1.5, binary_activation_reversed)

    def f(i):
        r = n3.calc([n1.calc(i), n2.calc(i)])
        return r

    dimension_test(4, f, True)
Exemplo n.º 4
0
def var_2():
    n1 = n([1, 1, -1], -2.5)
    n2 = n([1, -1, -1], -2.5)
    n3 = n([-1, 1, -1], -2.5)
    n4 = n([1, 1, 1], 2.5, binary_activation_reversed)

    def f(i):
        r = n4.calc([n1.calc(i), n2.calc(i), n3.calc(i)])
        return r

    dimension_test(3, f, True)
Exemplo n.º 5
0
def var_4():
    n1 = n([-1, 1, 1], 0.5, linear_activation)
    n2 = n([1, -1, 1], 0.5, linear_activation)
    n3 = n([-1, -1], 0.5)

    def f(i):
        r1 = n1.calc(i)
        r2 = n2.calc(i)
        r3 = n3.calc([r1, r2])
        return r3

    dimension_test(3, f)
Exemplo n.º 6
0
def var_4(x1, x2):
    n1 = n([1, -1], 0, linear_activation)
    n2 = n([1, -1], 0, linear_activation)
    n3 = n([0.5, 0.5], 0, linear_activation)
    n4 = n([1], 0, binary_activation)
    n5 = n([1], 0, binary_activation)

    def f(i, j):

        r1 = n1.calc([i, j])
        r2 = n2.calc([j, i])
        r3 = n3.calc([i, j])
        r4 = n4.calc([r1])
        r5 = n5.calc([r2])

        return r3, r4, r5

    halfsumm, max_1, max_2 = f(x1, x2)
    print("Mean " + str(x1) + " and " + str(x2) + " = " + str(halfsumm))
    if max_2 > max_1:
        print("Number " + str(x2) + " is greater than " + str(x1))
    else:
        print("Number " + str(x1) + " is greater than " + str(x2))
Exemplo n.º 7
0
def var_2():
    n1 = n([0.5, -1, 0.2], 0.5, linear_activation)
    n2 = n([1.5], 0.5, sqrt_activation)
    n3 = n([1.5], 0.5, sqrt_activation)

    def f(i, j, k):
        r1 = n1.calc([i, j, k], log=True)
        r2 = n2.calc([r1], log=True)
        r3 = n3.calc([r1], log=True)
        return r2, r3

    def plot(dots):
        import matplotlib.pyplot as plt
        results = [f(dot, 0, 0)[0] for dot in dots]
        fig = plt.figure()
        plt.plot(dots, results, 'ro')
        fig.suptitle('Task 5, Var 2', fontsize=20)
        plt.grid(True)
        plt.show()

    # print(f(1, -1, 1))
    import numpy as np
    plot(np.arange(-10., 10., 0.05))
Exemplo n.º 8
0
def var_3(x1, x2):
    n1 = n([1, -1], 0, linear_activation)
    n2 = n([1, -1], 0, linear_activation)
    n3 = n([1, -1], 0, modular_activation)
    n4 = n([1], 0, binary_activation_reversed)
    n5 = n([1], 0, binary_activation_reversed)

    def f(i, j):

        r1 = n1.calc([i, j])
        r2 = n2.calc([j, i])
        r3 = n3.calc([i, j])
        r4 = n4.calc([r1])
        r5 = n5.calc([r2])

        return r3, r4, r5

    difference_module, max_1, max_2 = f(x1, x2)
    print("Difference modulo  " + str(x1) + " и " + str(x2) + " = " +
          str(difference_module))
    if max_2 > max_1:
        print("Number " + str(x2) + " is smaller than " + str(x1))
    else:
        print("Number " + str(x1) + " is smaller than " + str(x2))