MCPcopy Create free account
hub / github.com/apple/ml-pointersect / BaseTrainProcess

Class BaseTrainProcess

cdslib/core/script/base_train.py:40–1202  ·  view source on GitHub ↗

r""" The base training procedure, including handling command line arguments through a yaml file, distributed data parallel, training loop, etc. It sets up a basic framework so that specific applications can easily extend. Example usage: .. code-block:: python if __name_

Source from the content-addressed store, hash-verified

38
39
40class BaseTrainProcess(ABC):
41 r"""
42 The base training procedure, including handling command line arguments
43 through a yaml file, distributed data parallel, training loop, etc.
44
45 It sets up a basic framework so that specific applications can easily extend.
46
47 Example usage:
48 .. code-block:: python
49 if __name__ == '__main__':
50 with TrainProcess() as trainer:
51 trainer.run()
52
53
54 Design logic:
55
56 - To configure the settings, you can use the arguments of init or config file.
57 But note that you should not use trainer file to configure the class.
58
59 """
60
61 def __init__(
62 self,
63 exp_tag: str = "exp",
64 config_filename: str = None,
65 trainer_filename: str = None,
66 work_dir: str = ".",
67 output_dir: str = None,
68 rank: int = 0,
69 n_gpus: int = 1,
70 random_seed: int = 0,
71 save_code: bool = True,
72 exclude_dirs: T.List[str] = None,
73 exp_tag_first: bool = False,
74 open_tensorboard: bool = True,
75 ddp_type: str = "ddp",
76 start_epoch: int = 0,
77 end_epoch: int = 1000000,
78 max_train_epoch_batches: int = -1,
79 max_valid_epoch_batches: int = -1,
80 max_test_epoch_batches: int = -1,
81 save_every_num_epoch: int = 1,
82 validate_every_num_epoch: int = 1,
83 test_every_num_epoch: int = 1,
84 log_every_num_train_batch: int = 1,
85 log_every_num_valid_batch: int = 1,
86 log_every_num_test_batch: int = 1,
87 visualize_every_num_train_batch: int = 1,
88 visualize_every_num_valid_batch: int = 1,
89 visualize_every_num_test_batch: int = 1,
90 tensorboard_exe_path: str = "tensorboard",
91 # overwrite_pretrained_names: T.List[str] = None,
92 use_torchrun: bool = True,
93 find_unused_parameters: bool = False, # used for DDP, see _setup_for_distributed_learning
94 *args,
95 **kwargs,
96 ):
97 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected