Repository navigation
Expand file tree
/
Copy patheval_models.py
More file actions
53 lines (42 loc) · 1.54 KB
/
Copy patheval_models.py
File metadata and controls
53 lines (42 loc) · 1.54 KB
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
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Evaluates a directory of models against the target model."""
import sys
sys.path.insert(0, '.') # nopep8
from tensorflow import gfile
import os
from absl import app
from reference_implementation import evaluate_model, wait
from rl_loop import fsdb
def load_train_times():
models = []
path = os.path.join(fsdb.models_dir(), 'train_times.txt')
with gfile.Open(path, 'r') as f:
for line in f.readlines():
line = line.strip()
if line:
timestamp, name = line.split(' ')
models.append((float(timestamp),
'tf,' + os.path.join(fsdb.models_dir(), name + '.pb')))
return models
def main(unused_argv):
sgf_dir = os.path.join(fsdb.eval_dir(), 'target')
target = 'tf,' + os.path.join(fsdb.models_dir(), 'target.pb')
models = load_train_times()
for i, (timestamp, name) in enumerate(models):
winrate = wait(evaluate_model(name, target, sgf_dir, i + 1))
if winrate >= 0.50:
break
if __name__ == '__main__':
app.run(main)