def test_Tanh1D(self): npr = np.tanh(self.np_a) dcr = dc.tanh(self.dc_a) np.testing.assert_allclose(npr, np.array(dcr.data()).astype(np.float32), rtol=1e-3, atol=1e-3)
def test_Tanh4D(self): np_a = np.reshape(self.np_a, (2, 2, 2, 3)) dc_a = dc.reshape(self.dc_a, (2, 2, 2, 3)) npr = np.tanh(np_a) dcr = dc.tanh(dc_a) np.testing.assert_allclose(npr.flatten(), np.array(dcr.data()).astype(np.float32), rtol=1e-3, atol=1e-3)
def test_nnScalar_tanh (self): np.testing.assert_allclose(np.tanh(self.random_number1), dc.tanh(self.random_number1), rtol=1e-3, atol=1e-3) np.testing.assert_allclose(np.tanh(self.random_number2), dc.tanh(self.random_number2), rtol=1e-3, atol=1e-3) np.testing.assert_allclose(np.tanh(self.random_number3), dc.tanh(self.random_number3), rtol=1e-3, atol=1e-3)