Пример #1
0
def test_input_exception():
    x = Variable([1, 1])
    with pytest.raises(ValueError):
        exp = F.Exponent()
        y = exp(x)
    with pytest.raises(ValueError):
        sin = F.Sinus()
        y = sin(x)
    with pytest.raises(ValueError):
        cos = F.Cosinus()
        y = cos(x)
    with pytest.raises(ValueError):
        tan = F.Tangent()
        y = tan(x)
    with pytest.raises(ValueError):
        arcsin = F.Arcsin()
        y = arcsin(x)
    with pytest.raises(ValueError):
        arccos = F.Arccos()
        y = arccos(x)
    with pytest.raises(ValueError):
        arctan = F.Arctan()
        y = arctan(x)
    with pytest.raises(ValueError):
        sinh = F.Sinh()
        y = sinh(x)
    with pytest.raises(ValueError):
        cosh = F.Cosh()
        y = cosh(x)
    with pytest.raises(ValueError):
        tanh = F.Tanh()
        y = tanh(x)
    with pytest.raises(ValueError):
        log = F.Log()
        y = log(x)
    with pytest.raises(ValueError):
        logi = F.Logistic()
        y = logi(x)
    with pytest.raises(ValueError):
        sqrt = F.Sqrt()
        y = sqrt(x)
def test_tan_exception():
    x = ReverseVariable(np.pi / 2)
    tan = F.Tangent()
    with pytest.raises(ValueError):
        y = tan(x)
def test_tan():
    x = ReverseVariable(np.pi / 4)
    tan = F.Tangent()
    y = tan(x)
    y.reverse()
    assert abs(y.val - 1) < 1e-4 and abs(x.grad - 2) < 1e-4
Пример #4
0
def test_tan():
    x = Variable(np.pi / 4)
    tan = F.Tangent()
    y = tan(x)
    assert abs(y.val - 1) < 1e-4 and abs(y.grad - 2) < 1e-4