(self, batch_size=16, train=True, cost=None)
return np.array([x, y]), lengths, x[:, :, :1]
Main method for generating train/test data.
        Generates batch_size random indices, which correspond to some stories (1-20) and then takes a random story
        for each of the generated task indices.
        It converts the stories to one hot and pads them.

        :param cost: used in copy task for curriculum learning, but not here
        :param train: sampling from train or test data
        :param batch_size:
        :return: data_batch, lenghts of the each sampled story and corresponding masks
Main method for generating train/test data.
        Generates batch_size random indices, which correspond to some stories (1-20) and then takes a random story
        for each of the generated task indices.
        It converts the stories to one hot and pads them.
Main method for generating train / test data . Generates batch_size random indices which correspond to some stories ( 1 - 20 ) and then takes a random story for each of the generated task indices . It converts the stories to one hot and pads them .
def generate_data(self, batch_size=16, train=True, cost=None):
        """
        Main method for generating train/test data.
        Generates batch_size random indices, which correspond to some stories (1-20) and then takes a random story
        for each of the generated task indices.
        It converts the stories to one hot and pads them.

        :param cost: used in copy task for curriculum learning, but not here
        :param train: sampling from train or test data
        :param batch_size:
        :return: data_batch, lenghts of the each sampled story and corresponding masks
        """
        task_indices = np.random.randint(0, self.n_tasks, batch_size)
        # task_ind = 0
        if train:
            task_names = [self.train_list[ind] for ind in task_indices]
            x_task_names_stories = [self.x_train_stories[task_name] for task_name in task_names]
            y_task_names_stories = [self.y_train_stories[task_name] for task_name in task_names]
        else:
            task_names = [self.test_list[ind] for ind in task_indices]
            x_task_names_stories = [self.x_test_stories[task_name] for task_name in task_names]
            y_task_names_stories = [self.y_test_stories[task_name] for task_name in task_names]
        x = []
        y = []
        for x_task_stories, y_task_stories in zip(x_task_names_stories, y_task_names_stories):
            story_ind = np.random.randint(0, len(x_task_stories))
            x.append(bAbITask.to_onehot(x_task_stories[story_ind], self.vector_size))
            y.append(bAbITask.to_onehot(y_task_stories[story_ind], self.vector_size))

        x, y, lengths = self.pad_stories(x, y)
        return np.array([x, y]), lengths, x[:, :, :1]
def generate_data ( self , batch_size = 16 , train = True , cost = None ) : task_indices = np . random . randint ( 0 , self . n_tasks , batch_size ) # task_ind = 0 if train : task_names = [ self . train_list [ ind ] for ind in task_indices ] x_task_names_stories = [ self . x_train_stories [ task_name ] for task_name in task_names ] y_task_names_stories = [ self . y_train_stories [ task_name ] for task_name in task_names ] else : task_names = [ self . test_list [ ind ] for ind in task_indices ] x_task_names_stories = [ self . x_test_stories [ task_name ] for task_name in task_names ] y_task_names_stories = [ self . y_test_stories [ task_name ] for task_name in task_names ] x = [ ] y = [ ] for x_task_stories , y_task_stories in zip ( x_task_names_stories , y_task_names_stories ) : story_ind = np . random . randint ( 0 , len ( x_task_stories ) ) x . append ( bAbITask . to_onehot ( x_task_stories [ story_ind ] , self . vector_size ) ) y . append ( bAbITask . to_onehot ( y_task_stories [ story_ind ] , self . vector_size ) ) x , y , lengths = self . pad_stories ( x , y ) return np . array ( [ x , y ] ) , lengths , x [ : , : , : 1 ]