Esempio n. 1
0
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
Esempio n. 2
0
    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
Esempio n. 3
0
def load(path, model_parameters):
    options = opts.load(path)
    optim = build(options, model_parameters)
    load_state(path, optim)
    return optim
Esempio n. 4
0
def load(path):
    options = opts.load(path)
    return build(options)
Esempio n. 5
0
def load(path, optim):
    options = opts.load(path)
    scheduler = build(options, optim)
    load_state(path, scheduler)
    return scheduler