-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy patheval.py
executable file
·47 lines (38 loc) · 1.19 KB
/
eval.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
import util
import logging
import json
import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='3'
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
from model import Optimizer
from rnn import MultiInputLSTM
from logger import get_handlers
from collections import namedtuple
logging.basicConfig(level=logging.INFO, handlers=get_handlers(False))
logger = logging.getLogger()
def main():
config_file = open('./config.json')
config = json.load(config_file,
object_hook=lambda d:namedtuple('x', d.keys())(*d.values()))
num_unrolls = config.num_steps // config.unroll_length
with tf.Session() as sess:
model = util.load_model(sess, config, logger)
all_y = []
for i in range(10):
print(i)
_, loss, reset, fx_array, x_array = model.step()
cost, others = util.run_epoch(sess, loss, [fx_array, x_array],
reset, num_unrolls)
Y, X = others
all_y.append(Y)
all_y = np.hstack(all_y)
np.save('srnn.npy', all_y)
plt.figure(1)
y_mean = np.mean(all_y, axis=1)
plt.plot(y_mean)
print(min(y_mean))
plt.show()
if __name__ == '__main__':
main()