The error i got: TypeError: plotImages() got an unexpected keyword argument ‘n_images’
Please do let me know if you have an idea. This is the code:
JavaScript
x
33
33
1
categoriesList=["airplane","automobile","bird", "cat", "deer", "dog", "frog", "horse", "ship", "truck"]
2
3
import matplotlib.pyplot as plt
4
import random
5
def plotImages(x_test, images_arr, labels_arr, nx_images=8):
6
fig, axes = plt.subplots(n_images, n_images, figsize=(9,9))
7
axes = axes.flatten()
8
9
for i in range(100):
10
rand = random.randint(0, x_test.shape[0] -1)
11
img = images_arr[rand]
12
ax = axes[i]
13
14
ax.imshow( img, cmap="Greys_r")
15
ax.set_xticks(())
16
ax.set_yticks(())
17
18
predict_x=model2000.predict([[x_test[rand]]])
19
label=categoriesList[predictions[0]]
20
21
if labels_arr[rand][predictions[0]] == 0:
22
ax.set_title(label, fontsize=18 - n_images, color="red")
23
else:
24
ax.set_title(label, fontsize=18 - n_images)
25
26
plot = plt.tight_layout()
27
return plot
28
29
display (plotImages(x_test, data_test_picture, y_test, n_images=10))
30
31
32
33
Advertisement
Answer
You defined the argument as nx_images
in function definition, but doesn’t seem to use it anywhere in the code. Try changing it.