我試圖找出爲什麼Session.run()給出會話圖形是空的錯誤。爲什麼Session.run()在這裏不起作用?不知怎的,我可以打印(預測)檢索結果。爲什麼tf.Session()。run()在這裏不起作用?
我不需要使用Session.run()來開始構建模型得到預測嗎?
def new_samples():
#return np.array([[5.9,3,4.2,1.5],[6.9,3.1,5.4,2.1]], dtype=np.float32)
return np.array(test_data_values, dtype=np.float32)
predictions = list(classifier.predict_classes(input_fn=new_samples))
default_session = tf.Session()
print(default_session.run(predictions))
注:分類= tf.contrib.learn.DNNClassifier
您應該構建模型啓動會話之前。然後會話將通過您構建的模型(圖)運行張量以獲得您的平常輸出(如numpy數組),因此您不需要使用sess.run來構建模型。 – kwotsin