-
Notifications
You must be signed in to change notification settings - Fork 25
/
main_pretrain.py
29 lines (24 loc) · 930 Bytes
/
main_pretrain.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
import numpy as np
import os,sys,time
import torch
import options,util
import model_pretrain
print(util.yellow("======================================================="))
print(util.yellow("main_pretrain.py (pretraining with AtlasNet reimplementation)"))
print(util.yellow("======================================================="))
print(util.magenta("setting configurations..."))
opt = options.set()
with torch.cuda.device(opt.gpu):
trainer = model_pretrain.Model(opt)
trainer.load_dataset(opt)
trainer.build_network(opt)
trainer.setup_optimizer(opt)
trainer.restore_checkpoint(opt)
trainer.setup_visualizer(opt)
print(util.yellow("======= TRAINING START ======="))
trainer.time_start(opt)
for ep in range(opt.from_epoch,opt.to_epoch):
trainer.train_epoch(opt,ep)
if (ep+1)%10==0: trainer.evaluate(opt,ep)
if (ep+1)%50==0: trainer.save_checkpoint(opt,ep)
print(util.yellow("======= TRAINING DONE ======="))