-
Notifications
You must be signed in to change notification settings - Fork 0
/
temp.py
31 lines (22 loc) · 935 Bytes
/
temp.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
import tensorflow as tf
sess=tf.Session()
# First let's load meta graph and restore weights
saver = tf.train.import_meta_graph('my_test_model-1000.meta')
saver.restore(sess, tf.train.latest_checkpoint('./'))
# Access saved Variables directly
print(sess.run('bias:0'))
# This will print 2, which is the value of bias that we saved
# Now, let's access and create placeholders variables and
# create feed-dict to feed new data
graph = tf.get_default_graph()
w1 = graph.get_tensor_by_name("w1:0")
w2 = graph.get_tensor_by_name("w2:0")
feed_dict = {w1: 13.0, w2: 17.0}
# Now, access the op that you want to run.
op_to_restore = graph.get_tensor_by_name("op_to_restore:0")
print(sess.run(op_to_restore, feed_dict))
# This will print 60 which is calculated
a = [n.name for n in tf.get_default_graph().as_graph_def().node]
# pooled = graph.get_tensor_by_name('normal/LeNet/cnn2/pooled:0')
# 'normal/x',
# 'normal/dropout/keep_prob',