-
Notifications
You must be signed in to change notification settings - Fork 0
/
train_hive.py
55 lines (40 loc) · 1.33 KB
/
train_hive.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
import logging
import random
import coloredlogs
import numpy as np
import torch
from hive.hive_conf import hive_args
from hive.hive_game import HiveGame
from hive.hive_ui import HiveUI
from hive.nn.hive_nn import HiveNNet
from src.coach import Coach
from src.nnet import NNetWrapper
from src.utils import *
import sys
sys.setrecursionlimit(1000)
log = logging.getLogger(__name__)
coloredlogs.install(level='INFO') # Change this to DEBUG to see more info.
def main():
log.info('Loading %s...', HiveGame.__name__)
g = HiveGame()
display = HiveUI(g)
log.info('Loading %s...', NNetWrapper.__name__)
conf = hive_args
nnet = HiveNNet(g,conf.nn)
model = NNetWrapper(g,nnet,conf.nn)
if conf.load_previous:
log.info(f'Atempting to load checkpoint from folder {conf.folder}')
file = model.load_checkpoint(conf.folder,conf.model_file)
log.info(f"Successfully loaded model: {file}")
else:
log.warning('Not loading a checkpoint!')
log.info('Loading the Coach...')
c = Coach(g, model, display=display, args=conf)
if conf.load_previous:
log.info("Loading 'trainExamples' from file...")
c.loadTrainExamples(conf.folder,conf.training_examples_file)
log.info('Starting the learning process 🎉')
c.learn()
if __name__ == "__main__":
fix_seed(1334)
main()