-
Notifications
You must be signed in to change notification settings - Fork 0
/
loader.py
69 lines (55 loc) · 1.96 KB
/
loader.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
63
64
65
66
67
68
69
"""
Updated: 2017
Author: Sergei Shliakhtin
Contact: xxx.serj@gmail.com
Notes:
Takes an input csv in the following format:
WAFER_COUNT, CYCLE_TIME
and sends it to main.py according to usual protocol (see README),
uses input filename as tool_recipe id;
Has some (disabled) abitlity to log results to tensorboards
"""
import argparse
import csv
import subprocess
import sys
import tensorflow as tf
from cycle_ml.aux import my_call
parser = argparse.ArgumentParser()
parser.add_argument("fname", default="", type=str)
parser.add_argument("--verbose", action="store_true")
args = parser.parse_args()
with tf.Session() as sess:
err = tf.Variable(6)
init_op = tf.global_variables_initializer()
sess.run(init_op)
writer = tf.summary.FileWriter("tboard", sess.graph)
total_error = tf.placeholder(tf.float32, name="error")
tf.summary.scalar("error", total_error)
summaries = tf.summary.merge_all()
fname = args.fname
print("Reading {}".format(fname))
with open(fname, newline="") as csv_file:
reader = csv.reader(csv_file)
step = 0
for row in reader:
try:
assert len(row) == 2, "Should have 2 columns"
wc = float(row[0])
ct = float(row[1])
print("\n")
cmd = ["python", "main.py", "--next_datapoint", str(wc), fname]
if args.verbose:
cmd.append("--verbose")
if 0 != my_call(cmd):
sys.exit(1)
print("\n")
abs_err = my_call(["python", "main.py", "--finish_datapoint", str(ct), fname])
print("ERROR ", abs_err)
feed_dict = { total_error: abs_err }
[summary] = sess.run([summaries], feed_dict)
writer.add_summary(summary, step)
step += 1
#print("\n")
except KeyboardInterrupt:
sys.exit(0)