2017-10-12 56 views

回答

0

我實際上已經找到了一個方法,這是非常簡單的,因爲我認爲。我在想,有些人可能會有類似的問題,所以在這裏。 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") 

}