Example #1
0
 def test_Min1D(self):
     npr = np.minimum(self.np_a, self.np_b)
     dcr = dc.min(dc.ftvec([self.dc_a, self.dc_b]))
     np.testing.assert_allclose(npr,
                                np.array(dcr.data()).astype(np.float32),
                                rtol=1e-3,
                                atol=1e-3)
Example #2
0
 def test_Min2D (self):
     np_a = np.reshape(self.np_a, (3,4))
     np_b = np.reshape(self.np_b, (3,4))
     dc_a = dc.reshape(self.dc_a, (3,4));
     dc_b = dc.reshape(self.dc_b, (3,4));
     npr = np.minimum(np_a, np_b)
     dcr = dc.min(dc_a, dc_b);
     np.testing.assert_allclose(npr.flatten(), np.array(dcr.data()).astype(np.float32),
             rtol=1e-3, atol=1e-3)
Example #3
0
    def test_Min4D(self):
        np_a = np.reshape(self.np_a, (2, 2, 3, 2))
        np_b = np.reshape(self.np_b, (2, 2, 3, 2))
        dc_a = dc.reshape(self.dc_a, (2, 2, 3, 2))
        dc_b = dc.reshape(self.dc_b, (2, 2, 3, 2))

        npr = np.minimum(np_a, np_b)
        dcr = dc.min(dc.vectorTensorFloat([dc_a, dc_b]))
        np.testing.assert_allclose(npr.flatten(),
                                   np.array(dcr.data()).astype(np.float32),
                                   rtol=1e-3,
                                   atol=1e-3)