Beispiel #1
0
    def test_sample_dropout_mask(self):
        for _ in range(20):
            height = 1000
            width = 10000
            dropout_prob = np.random.rand()
            X = sampler.gen_uniform((height, width), np.float32)
            dropout_mask = sample_dropout_mask(X, dropout_prob)
            dropout_rate = 1. - dropout_mask.get().mean()

            self.assertLess(np.abs(dropout_prob - dropout_rate), self.TOL)
            self.assertTrue(np.all((X.get() != 0.) == dropout_mask.get()))
Beispiel #2
0
    def test_sample_dropout_mask(self):
        for _ in range(20):
            height = 1000
            width = 10000
            dropout_prob = np.random.rand()
            X = sampler.gen_uniform((height, width), np.float32)
            dropout_mask = sample_dropout_mask(X, dropout_prob)
            dropout_rate = 1. - dropout_mask.get().mean()

            self.assertLess(np.abs(dropout_prob - dropout_rate), self.TOL)
            self.assertTrue(np.all((X.get() != 0.) == dropout_mask.get()))
Beispiel #3
0
    def test_sample_dropout_mask_columns(self):
        for _ in range(20):
            height = 10000
            width = 10000
            dropout_prob = np.random.rand()
            X = sampler.gen_uniform((height, width), np.float32)

            start = np.random.randint(0, width - 1000)
            end = start + 1000
            columns = (start, end)

            dropout_mask = sample_dropout_mask(X, dropout_prob, columns)
            dropout_rate = 1. - dropout_mask.get().mean()

            self.assertEqual(dropout_mask.shape, (X.shape[0], end - start))
            self.assertLess(np.abs(dropout_prob - dropout_rate), self.TOL)
            self.assertTrue(
                np.all((X.get()[:, start:end] != 0.) == dropout_mask.get()))
Beispiel #4
0
    def test_sample_dropout_mask_columns(self):
        for _ in range(20):
            height = 10000
            width = 10000
            dropout_prob = np.random.rand()
            X = sampler.gen_uniform((height, width), np.float32)

            start = np.random.randint(0, width - 1000)
            end = start + 1000
            columns = (start, end)

            dropout_mask = sample_dropout_mask(X, dropout_prob, columns)
            dropout_rate = 1. - dropout_mask.get().mean()

            self.assertEqual(dropout_mask.shape, (X.shape[0], end - start))
            self.assertLess(np.abs(dropout_prob - dropout_rate),
                            self.TOL)
            self.assertTrue(np.all((X.get()[:, start:end] != 0.)
                                   == dropout_mask.get()))