Esempio n. 1
0
def test_size(n: int = 10):
    a = np.ones(n)
    b = np.ones(n)
    c = np.ones(n)
    d = np.ones(n)

    assert size(a, b, c, d) == n
Esempio n. 2
0
def test_size_error():
    x = np.ones(10)
    y = np.ones(10)
    z = np.ones(5)

    with pytest.raises(ValueError):
        n = size(x, y, z)
Esempio n. 3
0
    def grad(self, predicted: Tensor, target: Tensor) -> float:
        n = size(predicted, target)

        return 2 * (predicted - target) / n
Esempio n. 4
0
    def loss(self, predicted: Tensor, target: Tensor) -> float:
        n = size(predicted, target)

        return np.sum((predicted - target)**2) / n
Esempio n. 5
0
def test_size_one(n: int = 10):
    x = np.ones(n)

    assert size(x) == n
Esempio n. 6
0
def test_size_no_args():
    with pytest.raises(ValueError):
        n = size()