我希望获得模型预测 from __future__ import print_function
from keras.models import Sequential
from keras.layers import Dense
import keras
import numpy as np
model = Sequential()
model.add(Dense(2000, input_dim=3072, activation='relu'))
model.add(Dense(500, activation='relu'))
model.add(Dense(66, activation='softmax'))
model.fit(x_train,y_train, epochs=100, batch_size=128)
scores = model.evaluate(x_train, y_train)
print("\n%s: %.2f%%" % (model.metrics_names[1], scores[1]*100))
predictions = model.predict(x_test)
现在我希望获得预测的准确性
print("\n%s: %.2f%%" % (model.metrics_names[1], predictions*100))
我尝试过:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-262-edbcf292f31c> in <module>()
----> 1 print("\n%s: %.2f%%" % (model.metrics_names[1], predictions*100))
TypeError: float argument required, not numpy.ndarray
我收到了以下错误:
WITH DATA AS (SELECT '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetDeliveryReportResponse xmlns="MyTest WebService">
<GetDeliveryReportResult>919748021520500 -3-4/6/2017 1:18:49 PM,919400159619-3-4/6/2017 1:19:20 PM,||rc_smsSND_NUMB-11-4/6/2017 6:10:00 PM,||rc_smsSND_NUMB-11-4/6/2017 6:11:00 PM</GetDeliveryReportResult>
</GetDeliveryReportResponse>
</soap:Body>
</soap:Envelope>' xml FROM dual)
SELECT did
FROM data,
xmltable(XMLNamespaces ('http://schemas.xmlsoap.org/soap/envelope/'
AS "soap"),
'/soap:Envelope/soap:Body/GetDeliveryReportResponse'
PASSING XMLTYPE(xml)
COLUMNS
did Varchar2(1000) PATH 'GetDeliveryReportResult');
答案 0 :(得分:1)
model.predict
生成的numpy.array
与float
完全不同。您可能尝试使用print(predictions)
进行打印,但在这种情况下,使用带float
的格式化字符串绝对不起作用。尝试:
print("\n%s:" % (model.metrics_names[1]))
print(100 * predictions)
或
print("\n%s: %s" % (model.metrics_names[1], np.array_str(predictions*100)))
或者x_test
只有一个案例:
print("\n%s: %.2f%%" % (model.metrics_names[1], predictions[0]*100))