def test_gradient_descent_test(): model = TestModel() optimiser = v.GradientDescentOptimiser(0.1, batch_size=1) error = v.SumSquared() xs = np.zeros((10, 2)) ys = np.zeros((10, 1)) optimiser.train(model, xs, ys, error) assert model.called_predict == 10 assert model.called_backward == 10 assert model.called_cache_reset == 10
def __init__(self, error_function=v.SumSquared()): super(ErrorCostCategorical, self).__init__(error_function) self.outputs = []
def __init__(self, error_function=v.SumSquared()): self.errors = [] self.hits = [] assert callable(error_function) self.error_function = error_function
def test_sum_squared_single(): xs = np.array(10) ys = np.array(12) assert v.SumSquared()(xs, ys) == 2
def test_sum_squared_prime(): xs = np.zeros((4)) ys = np.repeat(2, 4) expected = np.repeat(-2, 4) out = v.SumSquared().prime(xs, ys) assert np.allclose(out, expected)