예제 #1
0
파일: test_expm1.py 프로젝트: zzk0/oneflow
def _test_expm1_impl(test_case, device, shape):
    x = flow.tensor(
        np.random.randn(*shape),
        dtype=flow.float32,
        device=flow.device(device),
        requires_grad=True,
    )
    of_out = flow.expm1(x)
    np_out = np.expm1(x.numpy())
    test_case.assertTrue(np.allclose(of_out.numpy(), np_out, 0.0001, 0.0001))
    of_out = of_out.sum()
    of_out.backward()
    test_case.assertTrue(np.allclose(x.grad.numpy(), np.exp(x.numpy()), 0.0001, 0.0001))
예제 #2
0
def _expm1(self):
    return flow.expm1(self)
예제 #3
0
 def forward(self, x):
     return flow.expm1(x)