[英]How can I get use of trained Keras model to make new predictions?
i am a newbee of Keras. 我是Keras的新人。 When i am done with the Iris classification tutorial, i just confused with this, since we encoded those 3 kinds of iris flowers, for example, one-hot encoding. 当我完成Iris分类教程时,我只是对此感到困惑,因为我们编码了这3种鸢尾花,例如,单热编码。 We should get 3 orthogonal vectors right? 我们应该得到3个正交向量吗?
setosa [1 0 0]
versicolor [0 1 0]
virginica [0 0 1]
my model is the same as tutorial : 我的模型与教程相同:
http://machinelearningmastery.com/multi-class-classification-tutorial-keras-deep-learning-library/
and my question is although i got the result: 我的问题是虽然我得到了结果:
Baseline: 95.33% (4.27%)
but when i call the trained deep network model: 但当我打电话给训练有素的深层网络模型时:
prediction = baseline_model().predict(X)
where X is the orginal input when i trained the network 其中X是我训练网络时的原始输入
i got a very wired predictions such that: 我有一个非常有线的预测,这样:
print prediction
0,0,0
0,0,0
0,0,0
0,0,0
with all zero vectors, and i am supposed to get some one-hot encoded result right? 所有零向量,我应该得到一些单热编码结果吗? to identify which class the flower should be. 确定花应该是哪一类。
so how can i make use of my trained Keras model while im inputting the same input X and get the classify result to plot a graph?? 那么我如何利用我训练过的Keras模型同时输入相同的输入X并获得分类结果来绘制图形?
You need to train your network, and only then you can use it for prediction. 您需要训练您的网络,然后才能将其用于预测。 Using the notations from the tutorial, you may do: 使用教程中的符号,您可以:
estimator = KerasClassifier(build_fn=baseline_model, nb_epoch=200, batch_size=5, verbose=0)
X_train, X_test, Y_train, Y_test = train_test_split(X, dummy_y, test_size=0.33, random_state=seed)
estimator.fit(X_train, Y_train)
predictions = estimator.predict(X)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.