def test_HardSigmoid1D(self): npr = np.clip((self.alpha * self.np_a + self.beta), 0.0, 1.0) dcr = dc.hardsigmoid(self.dc_a, self.alpha, self.beta) np.testing.assert_allclose(npr, np.array(dcr.data()).astype(np.float32), rtol=1e-3, atol=1e-3)
def test_HardSigmoid3D_1(self): np_a = np.reshape(self.np_a, (2, 4, 3)) dc_a = dc.reshape(self.dc_a, (2, 4, 3)) npr = np.clip((self.alpha * np_a + self.beta), 0.0, 1.0) dcr = dc.hardsigmoid(dc_a, self.alpha, self.beta) np.testing.assert_allclose(npr.flatten(), np.array(dcr.data()).astype(np.float32), rtol=1e-3, atol=1e-3)