Esempio n. 1
0
 def test_Hardmax1D(self):
     npr = (self.np_a.max(0, keepdims=1) == self.np_a)
     dcr = dc.hardmax(self.dc_a, 1)
     np.testing.assert_allclose(npr,
                                np.array(dcr.data()).astype(np.float32),
                                rtol=1e-3,
                                atol=1e-3)
Esempio n. 2
0
 def test_Hardmax3D_2(self):
     np_a = np.reshape(self.np_a, (2, 2, 6))
     dc_a = dc.reshape(self.dc_a, (2, 2, 6))
     self.coerce(np_a)
     np_a = np.reshape(np_a, (self.axis1, self.axis2))
     npr = (np_a.max(0, keepdims=1) == np_a).astype(float)
     dcr = dc.hardmax(dc_a, self.axis)
     np.testing.assert_allclose(npr.flatten(),
                                np.array(dcr.data()).astype(np.float32),
                                rtol=1e-3,
                                atol=1e-3)