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))
def _expm1(self): return flow.expm1(self)
def forward(self, x): return flow.expm1(x)