コード例 #1
0
def test_MAE():
    x = Tensor(np.array([0.1, 0.2, 0.6, 0.9]))
    y = Tensor(np.array([0.1, 0.25, 0.7, 0.9]))
    error = MAE()
    error.clear()
    error.update(x, y)
    result = error.eval()
    assert math.isclose(result, 0.15 / 4)
コード例 #2
0
def test_input_MAE():
    x = Tensor(np.array([0.1, 0.2, 0.6, 0.9]))
    y = Tensor(np.array([0.1, 0.25, 0.7, 0.9]))
    error = MAE()
    error.clear()
    with pytest.raises(ValueError):
        error.update(x, y, x)
コード例 #3
0
def test_zero_MAE():
    error = MAE()
    with pytest.raises(RuntimeError):
        error.eval()