This repository has been archived by the owner on Sep 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathtrain.py
56 lines (45 loc) · 1.48 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
import os
import torch
import numpy as np
import random
from pytorch_lightning import Trainer
from pytorch_lightning.callbacks import ModelCheckpoint
from argparse import ArgumentParser
from models.denoise import PointCloudDenoising
def main(hparams):
torch.manual_seed(hparams.seed)
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
np.random.seed(hparams.seed)
random.seed(hparams.seed)
module = PointCloudDenoising(hparams)
if hparams.debug:
trainer = Trainer(
gpus=hparams.n_gpu,
fast_dev_run=True,
logger=False,
checkpoint_callback=False,
distributed_backend='dp'
)
else:
trainer = Trainer(
gpus=hparams.n_gpu,
early_stop_callback=None,
distributed_backend='dp',
)
os.makedirs('./lightning_logs', exist_ok=True)
os.makedirs(trainer.logger.log_dir)
trainer.checkpoint_callback = ModelCheckpoint(
filepath = trainer.logger.log_dir,
save_top_k=-1
)
trainer.fit(module)
if __name__ == '__main__':
parser = ArgumentParser(add_help=False)
parser.add_argument('--debug', action='store_true')
parser.add_argument('--n_gpu', type=int, default=1)
parser.add_argument('--seed', type=int, default=2020)
parser = PointCloudDenoising.add_model_specific_args(parser)
# parse params
hparams = parser.parse_args()
main(hparams)