所以我有以下numpy数组。
X_val: (47151, 32, 32, 1)
y_val_dummy: (47151, 5, 10)
y_pred: (47151, 5, 10)
当我运行代码时,似乎需要永远。有人可以建议为什么?我相信这是一个代码效率问题。我似乎无法完成这个过程。
y_pred_list = model.predict(X_val)
correct_preds = 0
# Iterate over sample dimension
for i in range(X_val.shape[0]):
pred_list_i = [y_pred_array[i] for y_pred in y_pred_array]
val_list_i = [y_val_dummy[i] for y_val in y_val_dummy]
matching_preds = [pred.argmax(-1) == val.argmax(-1) for pred, val in zip(pred_list_i, val_list_i)]
correct_preds = int(np.all(matching_preds))
total_acc = correct_preds / float(x_val.shape[0])