MCPcopy Create free account
hub / github.com/modelscope/modelscope / train

Method train

modelscope/trainers/trainer.py:685–712  ·  view source on GitHub ↗

Start training. Args: checkpoint_path(`str`, `optional`): The previous saving checkpoint to read, usually it's a `some-file-name.pth` file generated by this trainer. load_all_state(`bool`: `optional`): Load all state out of the `checkpoint_path` file,

(self,
              checkpoint_path=None,
              load_all_state=True,
              *args,
              **kwargs)

Source from the content-addressed store, hash-verified

683 load_ckpt_hooks[0].strict = strict
684
685 def train(self,
686 checkpoint_path=None,
687 load_all_state=True,
688 *args,
689 **kwargs):
690 """Start training.
691
692 Args:
693 checkpoint_path(`str`, `optional`): The previous saving checkpoint to read,
694 usually it's a `some-file-name.pth` file generated by this trainer.
695 load_all_state(`bool`: `optional`): Load all state out of the `checkpoint_path` file, including the
696 state dict of model, optimizer, lr_scheduler, the random state and epoch/iter number. If False, only
697 the model's state dict will be read, and model will be trained again.
698 kwargs:
699 strict(`boolean`): If strict, any unmatched keys will cause an error.
700 """
701
702 self._mode = ModeKeys.TRAIN
703 self.train_dataloader = self.get_train_dataloader()
704 self.data_loader = self.train_dataloader
705 self.register_optimizers_hook()
706 self.register_processors()
707 self.print_hook_info()
708 self.set_checkpoint_file_to_hook(checkpoint_path, load_all_state,
709 kwargs.get('strict', False))
710 self.model.train()
711
712 self.train_loop(self.train_dataloader)
713
714 def predict(self,
715 predict_datasets: Union[Dataset, List[Dataset]],

Callers 2

train_stepMethod · 0.45
train_loopMethod · 0.45

Calls 7

get_train_dataloaderMethod · 0.95
register_processorsMethod · 0.95
print_hook_infoMethod · 0.95
train_loopMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected