Exemplo n.º 1
0
    def load_state(self, path):
        from magnet.training.utils import load_state, load_object

        for i, model in enumerate(self.models): load_state(model, path / 'models', alternative_name=str(i))
        for i, optimizer in enumerate(self.optimizers): load_state(optimizer, path / 'optimizers', alternative_name=str(i))

        state_dict = load_object(path / 'state.p', default={})
        for attr, val in state_dict.items(): self.register_parameter(attr, val)

        try: self.callbacks('load_state', trainer=self, path=path / 'callbacks')
        except AttributeError: pass

        try: self.dataloader.load_state_dict(path / 'dataloader.p')
        except AttributeError: pass
Exemplo n.º 2
0
 def load_state(self, trainer, path):
     from magnet.training.utils import load_object
     state_dict = load_object(path / self.name / 'dataloader.p',
                              default=None)
     if state_dict is not None:
         trainer.dataloader.load_state_dict(state_dict)
Exemplo n.º 3
0
 def load_state(self, path):
     from magnet.training.utils import load_object
     self.history = load_object(path / self.name / 'history.p',
                                default=self.history)