[英]Python TypeError: got an unexpected keyword argument 'name'
[英]TypeError: plotImages() got an unexpected keyword argument 'n_images' Python
我得到的錯誤:TypeError: plotImages() got an unexpected keyword argument 'n_images'
如果您有想法,請告訴我。 這是代碼:
categoriesList=["airplane","automobile","bird", "cat", "deer", "dog", "frog", "horse", "ship", "truck"]
import matplotlib.pyplot as plt
import random
def plotImages(x_test, images_arr, labels_arr, nx_images=8):
fig, axes = plt.subplots(n_images, n_images, figsize=(9,9))
axes = axes.flatten()
for i in range(100):
rand = random.randint(0, x_test.shape[0] -1)
img = images_arr[rand]
ax = axes[i]
ax.imshow( img, cmap="Greys_r")
ax.set_xticks(())
ax.set_yticks(())
predict_x=model2000.predict([[x_test[rand]]])
label=categoriesList[predictions[0]]
if labels_arr[rand][predictions[0]] == 0:
ax.set_title(label, fontsize=18 - n_images, color="red")
else:
ax.set_title(label, fontsize=18 - n_images)
plot = plt.tight_layout()
return plot
display (plotImages(x_test, data_test_picture, y_test, n_images=10))
您在 function 定義中將參數定義為nx_images
,但似乎沒有在代碼中的任何地方使用它。 嘗試改變它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.