def load(path, fields_tuples, current_gpu_id): options = opts.load(path) # set gpu device to the current device options.gpu_id = current_gpu_id # hack: set dummy loss_weights (the correct values are going to be loaded) tags_field = dict(fields_tuples)['tags'] loss_weights = None if options.loss_weights == 'balanced': loss_weights = [0] * (len(tags_field.vocab) - 1) model = build(options, fields_tuples, loss_weights) load_state(path, model) return model
def load(self, dir_path): # load options from the json file self.options = opts.load(dir_path) # load vocabularies for each field fields.load_vocabs(dir_path, self.fields_tuples) # set the current gpu self.options.gpu_id = self.gpu_id # load model, optimizer and scheduler self.model = models.load(dir_path, self.fields_tuples, self.gpu_id) self.optimizer = optimizer.load(dir_path, self.model.parameters()) self.scheduler = scheduler.load(dir_path, self.optimizer) # now we have a loaded tagger self._loaded = True
def load(path, model_parameters): options = opts.load(path) optim = build(options, model_parameters) load_state(path, optim) return optim
def load(path): options = opts.load(path) return build(options)
def load(path, optim): options = opts.load(path) scheduler = build(options, optim) load_state(path, scheduler) return scheduler