def __init__(self, tasks, testingTasks=[], cuda=False): self.lexicon = set( flatten((t.examples for t in tasks + testingTasks), abort=lambda x: isinstance(x, str))).union( {"LIST_START", "LIST_END", "?"}) # Calculate the maximum length self.maximumLength = float( 'inf') # Believe it or not this is actually important to have here self.maximumLength = max( len(l) for t in tasks + testingTasks for xs, y in self.tokenize(t.examples) for l in [y] + [x for x in xs]) self.recomputeTasks = True super(LearnedFeatureExtractor, self).__init__(lexicon=list(self.lexicon), tasks=tasks, cuda=cuda, H=self.H, bidirectional=True)
def __init__(self, tasks, testingTasks=[], cuda=False): self.lexicon = set( flatten((t.examples for t in tasks + testingTasks), abort=lambda x: isinstance(x, str))).union( {"LIST_START", "LIST_END", "?"}) self.num_examples_list = [len(t.examples) for t in tasks] # Calculate the maximum length self.maximumLength = POSITIVEINFINITY self.maximumLength = max( len(l) for t in tasks + testingTasks for xs, y in self.tokenize(t.examples) for l in [y] + [x for x in xs]) super(LearnedFeatureExtractor, self).__init__(lexicon=list(self.lexicon), tasks=tasks, cuda=cuda, H=self.H, bidirectional=True) self.parallelTaskOfProgram = False