forked from wolny/pytorch-3dunet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
train.py
38 lines (28 loc) · 1.07 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
import random
import torch
import argparse
# from pytorch3dunet.unet3d.config import load_config
# from pytorch3dunet.unet3d.trainer import create_trainer
# from pytorch3dunet.unet3d.utils import get_logger
from pytorch3dunet.unet3d.config import load_config
from pytorch3dunet.unet3d.trainer import create_trainer
from pytorch3dunet.unet3d.utils import get_logger
logger = get_logger('TrainingSetup')
def main():
# Load and log experiment configuration
config = load_config()
logger.info(config)
manual_seed = config.get('manual_seed', None)
if manual_seed is not None:
logger.info(f'Seed the RNG for all devices with {manual_seed}')
logger.warning('Using CuDNN deterministic setting. This may slow down the training!')
random.seed(manual_seed)
torch.manual_seed(manual_seed)
# see https://pytorch.org/docs/stable/notes/randomness.html
torch.backends.cudnn.deterministic = True
# create trainer
trainer = create_trainer(config)
# Start training
trainer.fit()
if __name__ == '__main__':
main()