0
我正在關注本教程鏈接https://www.tensorflow.org/tutorials/layers中的Tensorflow的「圖層模塊」。您可能能夠幫助我如何獲得預測結果及其各自的概率。 我需要查看它以進一步瞭解模型。如果有辦法,我可以將結果 - 預測和概率保存到csv。Tensorflow:從「圖層模塊」提取預測
非常感謝你的時間。
我正在關注本教程鏈接https://www.tensorflow.org/tutorials/layers中的Tensorflow的「圖層模塊」。您可能能夠幫助我如何獲得預測結果及其各自的概率。 我需要查看它以進一步瞭解模型。如果有辦法,我可以將結果 - 預測和概率保存到csv。Tensorflow:從「圖層模塊」提取預測
非常感謝你的時間。
我實際上已經找到了一個方法,這是非常簡單的,因爲我認爲。我在想,有些人可能會有類似的問題,所以在這裏。 Tensorflow是一種適用於機器學習模型的新框架,但我最終意識到這非常簡單。
Tensorflow對你與TF創建的模型中,這* .predict(...)函數返回的預測變量定義你的模型包含「類」和「概率」
您的手機型號對於一個例子:
some_classifier = tf.estimator.Estimator(model_fn=model_fn,
model_dir=...)
您可以預測做到這一點(因爲我們知道它)
prediction_input_fn = tf.estimator.inputs.numpy_input_fn(
x={"x": test_feats}, #given you have this variable containing the test data
y=test_labels, #and the equivalent label for the test data
num_epochs=1,
shuffle=False)
prediction_results = some_classifier.predict(input_fn=prediction_input_fn)
,然後變量prediction_r esults包含預測類和值的概率,然後可以保存(例如,使用熊貓)
save = panda.DataFrame(list(prediction_results))
save.to_csv("file.csv")
上面的代碼剪斷效果很好給你已經寫了代碼模型內的容器的預測,如下面:
predictions = {
"classes": tf.argmax(input=logits, axis=1),
"probabilities": tf.nn.softmax(logits, name="softmax_tensor")
}