Пример #1
0
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
Пример #2
0
 def __init__(self, error_function=v.SumSquared()):
     super(ErrorCostCategorical, self).__init__(error_function)
     self.outputs = []
Пример #3
0
    def __init__(self, error_function=v.SumSquared()):
        self.errors = []
        self.hits = []

        assert callable(error_function)
        self.error_function = error_function
Пример #4
0
def test_sum_squared_single():
    xs = np.array(10)
    ys = np.array(12)
    assert v.SumSquared()(xs, ys) == 2
Пример #5
0
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)