def test_custom_operators(self): iterable = [MockCustomOperators(i) for i in range(1, 5)] assert averaged(lambda x: x, iterable).value == 2.5
def test_supports_booleans(self): iterable = [True] * 5 + [False] * 5 random.shuffle(iterable) assert averaged(lambda x: x, iterable) == 0.5
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
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
def compute_error(network, weights, examples): return averaged(examples, lambda x: float(np.argmax(x.target) != np.argmax(network.feed(weights, x.data))))