def setUp(self): super(LSTMTestCase, self).setUp() data, labels = reber.make_reber_classification(n_samples=100, return_indeces=True) data = add_padding(data + 1) # +1 to shift indeces self.data = train_test_split(data, labels, test_size=0.2) self.n_categories = len(reber.avaliable_letters) + 1 self.n_time_steps = self.data[0].shape[1]
data_matrix[i, -len(sample):] = sample return data_matrix # An example of possible values for the `data` and `labels` # variables # # >>> data # array([array([1, 3, 1, 4]), # array([0, 3, 0, 3, 0, 4, 3, 0, 4, 4]), # array([0, 3, 0, 0, 3, 0, 4, 2, 4, 1, 0, 4, 0])], dtype=object) # >>> # >>> labels # array([1, 0, 0]) data, labels = reber.make_reber_classification(n_samples=10000, return_indeces=True) # Shift all indeces by 1. In the next row we will add zero # paddings, so we need to make sure that we will not confuse # paddings with zero indeces. data = data + 1 # Add paddings at the beggining of each vector to make sure # that all samples has the same length. This trick allows to # train network with multiple independent samples. data = add_padding(data) x_train, x_test, y_train, y_test = train_test_split(data, labels, train_size=0.8)