Beispiel #1
0
    def test_middle_of_batches_are_all_zero_onehots(self):
        env = OneCharMemory(n=3, num_steps=4)
        X, Y = env.get_batch(batch_size=100)

        self.assertNpArrayConstant(X[:, 1:, 1:], 0)
        self.assertNpArrayConstant(Y[:, :-1, 1:], 0)
        self.assertNpArrayConstant(X[:, 1:, 0], 1)
        self.assertNpArrayConstant(Y[:, :-1, 0], 1)
Beispiel #2
0
    def test_target_is_never_zero_one_hot(self):
        env = OneCharMemory(n=3, num_steps=4)
        X, Y = env.get_batch(batch_size=100)

        self.assertNpArrayConstant(np.sum(X[:, 0, 0]), 0)
Beispiel #3
0
    def test_first_x_is_one_hot(self):
        env = OneCharMemory(n=3, num_steps=4)
        X, Y = env.get_batch(batch_size=100)

        self.assertNpArrayConstant(np.sum(np.array(1 == X[:, 0, :]), axis=1), 1)
Beispiel #4
0
    def test_batch_x_first_and_y_last_are_equal(self):
        env = OneCharMemory(n=3, num_steps=4)
        X, Y = env.get_batch(batch_size=100)

        self.assertNpEqual(X[:, 0, :], Y[:, -1, :])
Beispiel #5
0
    def test_get_batch_shape(self):
        env = OneCharMemory(n=5, num_steps=100)
        X, Y = env.get_batch(batch_size=3)

        self.assertEqual(X.shape, (3, 100, 6))
        self.assertEqual(Y.shape, (3, 100, 6))