求助!!! 帮忙解决:TypeError: only integer scalar arrays can be converted to a scalar index

不多说了,直接上代码,希望大神帮帮!谢谢了~

test_labels[100]

array([0., 0., 0., 0., 1., 0., 0., 0., 0., 0.], dtype=float32)

def plot_images(i,predictions_array,true_label,img):
    predictions_array,true_label,img = predictions_array,true_label,img[i]
    plt.grid(False)
    plt.xticks(range(10))
    plt.yticks([])

    plt.imshow(img)

    predicted_label = np.array(predictions_array)
    if predicted_label == true_label:
        color = 'blue'
    else:
        color = 'red'
#(np.array(class_names)[train_labels[i]])     
    plt.xlabel("{} {:2.0f}% ({})".format(class_names[predicted_label],
                                        100*np.max(predictions_array),
                                        class_names[true_label]),color=color)

def plot_value_array(i,predictions_array,true_label):
    predictions_array,true_label = predictions_array,true_label[i]
    plt.grid(False)
    plt.xticks(range(10))
    plt.yticks([])
    thisplot = plt.bar(range(10), predictions_array, color="#777777")    
    plt.ylim([0, 1])
    predicted_label = np.argmax(predictions_array)

    thisplot[predicted_label].set_color('red')
    thisplot[true_label].set_color('blue')

i = 0
plt.figure(figsize=[6,3])
plt.subplot(1,2,1)
plot_images(i,predictions[i],test_labels,test_images)
plt.subplot(1,2,2)
plot_value_array(i,predictions[i],test_labels)
plt.show()

报错内容:
TypeError Traceback (most recent call last)
in
2 plt.figure(figsize=[6,3])
3 plt.subplot(1,2,1)
----> 4 plot_images(i,predictions[i],test_labels,test_images)
5 plt.subplot(1,2,2)
6 plot_value_array(i,predictions[i],test_labels)

in plot_images(i, predictions_array, true_label, img)
13 color = 'red'
14 #(np.array(class_names)[train_labels[i]])
---> 15 plt.xlabel("{} {:2.0f}% ({})".format(class_names[predicted_label],
16 100*np.max(predictions_array),
17 class_names[true_label]),color=color)

TypeError: only integer scalar arrays can be converted to a scalar index

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 以帮助更多的人 ^-^