Exemplo n.º 1
0
def test_copysign():
    A = np.ones((INT_OVERFLOW, 2))
    #A.attach_grad()
    #with mx.autograd.record():
    B = np.copysign(A, -1)
    assert B.shape == (INT_OVERFLOW, 2)
    assert B[0][0] == -1
Exemplo n.º 2
0
def test_copysign():
    inp1 = np.ones((INT_OVERFLOW, 2))
    inp1[-1, -1] = 2
    inp1.attach_grad()
    inp2 = np.array([-1])
    with mx.autograd.record():
        out = np.copysign(inp1, inp2)
        out.backward()
    assert out.shape == (INT_OVERFLOW, 2)
    assert out[-1 ,-1] == -2
    assert inp1.grad.shape == (INT_OVERFLOW, 2)
    assert inp1.grad[-1, -1] == -1