Exemplo n.º 1
0
def classify_with_random_network_test():
    # given
    pysbp.init()
    pysbp.add_layer([0.5, 0.5, 0.5])

    # when
    answer = pysbp.classify([1, 0])

    # then
    assert all(a >= 0.0 and a <= 1.0 for a in answer),\
        "Some values in {} aren't from range [0,1]".format(answer)
Exemplo n.º 2
0
def load_xor_network_and_classify_test():
    # given
    pysbp.init()
    pysbp.add_layer([43.259, 43.268, -66.366], [65.075, 65.101, -27.079])
    pysbp.add_layer([-29.041, 27.2972, -5.0622])

    examples = [[[0.0, 0.0], [0.0]],
                [[1.0, 0.0], [1.0]],
                [[0.0, 1.0], [1.0]],
                [[1.0, 1.0], [0.0]]]

    # when
    def check_examples(input, output):
        answer = pysbp.classify(input)
        assert abs(answer[0] - output[0]) < EPS, \
            "Network answer for {} should be {}, not {}".format(
                input, output, answer)

    # then
    for input, output in examples:
        yield check_examples, input, output