我想檢查卷積層的過濾器。爲此,我試圖在會話的最後一步獲取變量。如何從會話中的圖表中獲取變量?
這裏是我的模型的簡化版本:
graph = tf.Graph()
with graph.as_default():
# Placeholders
...
# Variables.
conv1_w = tf.Variable(..., name='conv1_w')
...
optimizer = ...
accuracy = ...
with tf.Session(graph=graph) as session:
...
acc, c1 = session.run([accuracy, conv1_w], feed_dict=feed_test)
我得到下面的異常
Fetch argument <tensorflow.python.ops.variables.Variable object at 0x137890710> cannot be interpreted as a Tensor. (Tensor Tensor("conv1_w:0", shape=(5, 5, 1, 16), dtype=float32_ref) is not an element of this graph.)
但是,如果我申請的運算,我能賣到沒有錯誤產生的張量:
c1_op = tf.mul(conv1_w,1.0)
optimizer = ...
accuracy = ...
不Tensorflow不允許獲取變量?
應該沒有吧是ACC,conv_val = session.run([精度,conv1_w],feed_dict = feed_test) – Steven
它是一個錯字。我編輯的問題 – znat