-
Notifications
You must be signed in to change notification settings - Fork 2
/
train.py
33 lines (24 loc) · 813 Bytes
/
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
from configs import cfg
from core.utils.log_util import Logger
from core.data import create_dataloader
from core.nets import create_network
from core.train import create_trainer, create_optimizer
def main():
log = Logger()
log.print_config()
model = create_network()
optimizer = create_optimizer(model)
trainer = create_trainer(model, optimizer)
train_loader = create_dataloader(data_type='train', dataset_mode='cat_level')
# estimate start epoch
epoch = trainer.iter // len(train_loader) + 1
while True:
if trainer.iter > cfg.train.maxiter:
break
trainer.train(epoch=epoch,
train_dataloader=train_loader,
)
epoch += 1
trainer.finalize()
if __name__ == '__main__':
main()