-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_pqc.py
62 lines (45 loc) · 1.85 KB
/
main_pqc.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
57
58
59
60
61
62
import logging
import time
import coloredlogs
from Coach import Coach
from othello.OthelloGame import OthelloGame as Game
from othello.tfq.NNet import NNetWrapper as nn
from utils import *
log = logging.getLogger(__name__)
coloredlogs.install(level='INFO') # Change this to DEBUG to see more info.
args = dotdict({
'numIters':20,
'numEps': 100, #100 # Number of complete self-play games to simulate during a new iteration.
'tempThreshold': 15, #
'updateThreshold': 0.49, # During arena playoff, new neural net will be accepted if threshold or more of games are won.
'maxlenOfQueue': 200000, #64000 = 1000 bataches for training #200000 # Number of game examples to train the neural networks.
'numMCTSSims': 25, #25 # Number of games moves for MCTS to simulate.
'arenaCompare': 40, #40 # Number of games to play during arena play to determine if new net will be accepted.
'cpuct': 1,
'checkpoint': './pqc2_3/',
'load_model': True,
'load_folder_file': ('./pqc2_2/','best'),
'numItersForTrainExamplesHistory': 20, #20
})
def main():
log.info('Loading %s...', Game.__name__)
g = Game(4)
log.info('Loading %s...', nn.__name__)
nnet = nn(g)
if args.load_model:
log.info('Loading checkpoint "%s/%s"...', args.load_folder_file[0], args.load_folder_file[1])
nnet.load_checkpoint(args.load_folder_file[0], args.load_folder_file[1])
else:
log.warning('Not loading a checkpoint!')
log.info('Loading the Coach...')
c = Coach(g, nnet, args)
if args.load_model:
log.info("Loading 'trainExamples' from file...")
c.loadTrainExamples()
log.info('Starting the learning process 🎉')
start = time.time()
c.learn()
stop = time.time()
print(f"Training time: {stop - start}s")
if __name__ == "__main__":
main()