forked from MIT-SPARK/PD-MeshNet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrain.py
57 lines (51 loc) · 2.16 KB
/
train.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import argparse
import os
from pd_mesh_net.utils import BaseTrainingJob
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument(
'--f',
type=str,
help="Path to the folder containing the pretrained model to evaluate "
"and the training parameters.",
required=True)
parser.add_argument(
'--checkpoint_batch_frequency',
type=int,
help=
"Frequency (in batches) of checkpoint saving; if passed, overrides the "
"argument `checkpoint_epoch_frequency`.")
parser.add_argument('--checkpoint_epoch_frequency',
type=int,
help="Frequency (in epochs) of checkpoint saving.",
default=1)
parser.add_argument('--last_epoch',
type=int,
help="Last training epoch.",
required=True)
parser.add_argument('--verbose',
help="If passed, will display verbose prints.",
action='store_true')
args = parser.parse_args()
training_job_folder = os.path.abspath(args.f)
assert (os.path.exists(training_job_folder)
), f"Could not find the training job folder {training_job_folder}."
log_folder = os.path.dirname(training_job_folder)
training_job_name = os.path.basename(training_job_folder)
checkpoint_batch_frequency = None
checkpoint_epoch_frequency = args.checkpoint_epoch_frequency
if (args.checkpoint_batch_frequency):
checkpoint_batch_frequency = args.checkpoint_batch_frequency
checkpoint_epoch_frequency = None
print("Saving checkpoints in epoch-and-batch format, with a checkpoint "
"saved every {checkpoint_batch_frequency} checkpoints.")
# Create training job.
training_job = BaseTrainingJob(
final_training_epoch=args.last_epoch,
log_folder=log_folder,
checkpoint_batch_frequency=checkpoint_batch_frequency,
checkpoint_epoch_frequency=checkpoint_epoch_frequency,
training_job_name=training_job_name,
verbose=args.verbose)
# Run training job.
training_job.train()