2017-05-31 175 views
0

inception/inception_eval.py,我想打印標籤和logits。如何打印tensorflow張量

我嘗試了一些方法,但他們不工作。
我怎樣才能得到這些張量的數量?

with tf.Graph().as_default(): 
# Get images and labels from the dataset. 

# with tf.Session() as sess: 
# images, labels = image_processing.inputs(dataset) 
# print ("lable") 
# sess.run (labels.eval()) 
images, labels = image_processing.inputs(dataset) 
# sess = tf.Session() 
# print("lable") 
# print (labels) 
# Number of classes in the Dataset label set plus 1. 
# Label 0 is reserved for an (unused) background class. 
num_classes = dataset.num_classes() + 1 

# Build a Graph that computes the logits predictions from the 
# inference model. 
logits, _ = inception.inference(images, num_classes) 
print ("logits") 
# print (tf.cast(logits,tf.float32).eval()) 
# print ("_") 
# print (tf.cast(_,tf.float32).eval()) 
+0

我已經解決了這個問題。 https://github.com/Youngkl0726/Inception/blob/master/inception/inception_eval.py這是解決方案。 – youngkl

回答

0

如果將檢查inception_model文件,你會看到inference function回報你們兩個張量:

Logits。二維浮動張量。

輔助對象。二維浮動張量 側頭。僅用於訓練。

所以你只需要創建一個會話並在此會話中運行這個張量。