我使用以下內容從我的 keras 模型中進行預測:
# fit the keras model on the dataset
ker_model.fit(xtrain, ytrain, epochs=200, verbose=0)
predictions = ker_model.predict(xtest)
predictions = predictions.astype(int)
predictions.mean()
predictions
然而,問題是,我的預測是在一個嵌套陣列串列中。這意味著它看起來如下:
array([[0],
[0],
[0],
[1],
[1]])
如何確保我的預測最終不會出現在這樣的嵌套串列中,或者取消列出預測?
我希望我的輸出看起來像:
array([0, 0, 0, 1, 1])
uj5u.com熱心網友回復:
你可以使用
predictions =predictions.ravel()
或
predictions =predictions.squeeze()
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/405975.html
標籤:
