我正在尝试创建一个包含 image_id 然后几个预测百分比的列表。预测百分比 (yhat) 在 np 数组中。我认为使用“tolist”然后“扩展”然后“附加”应该可以工作。我一定做错了什么。非常感谢您的帮助!
# Predict the probability across all output classes.
yhat = model.predict(image_array) #the image predictions
yhat.tolist() #change array to list
row = [i[0]] #the image id
row.extend(yhat) #add list elements to row
result_yhat.append(row) #append row to result_yhat
结果仍然具有数组中的预测数字。
result_yhat
[['5', array([6.78813876e-07, 1.14646399e-08, 5.51704140e-08,
9.05712838e-08,...