Exemple #1
0
 def test_custom_operators(self):
     iterable = [MockCustomOperators(i) for i in range(1, 5)]
     assert averaged(lambda x: x, iterable).value == 2.5
Exemple #2
0
 def test_supports_booleans(self):
     iterable = [True] * 5 + [False] * 5
     random.shuffle(iterable)
     assert averaged(lambda x: x, iterable) == 0.5
Exemple #3
0
 def test_result(self):
     assert averaged(lambda x: x, [1, 2, 3, 4]) == 2.5
     assert averaged(lambda x: x**2, [1, 2, 3, 4]) == 7.5
Exemple #4
0
 def test_supports_booleans(self):
     iterable = [True] * 5 + [False] * 5
     random.shuffle(iterable)
     assert averaged(lambda x: x, iterable) == 0.5
Exemple #5
0
 def test_custom_operators(self):
     iterable = [MockCustomOperators(i) for i in range(1, 5)]
     assert averaged(lambda x: x, iterable).value == 2.5
Exemple #6
0
 def test_result(self):
     assert averaged(lambda x: x, [1, 2, 3, 4]) == 2.5
     assert averaged(lambda x: x ** 2, [1, 2, 3, 4]) == 7.5
Exemple #7
0
def compute_error(network, weights, examples):
    return averaged(examples, lambda x:
        float(np.argmax(x.target) !=
        np.argmax(network.feed(weights, x.data))))