我正在为DCNN模型编写分类报告,但我面临一个错误。我的代码是
from sklearn.metrics import confusion_matrix
test = ImageDataGenerator()
test_generator = tf.keras.preprocessing.image.ImageDataGenerator(rescale=1./255)
test_data = test_generator.flow_from_directory(directory="/content/dataset/test",target_size=IMAGE_SHAPE , color_mode="rgb" , class_mode='categorical' , batch_size=1 , shuffle = False )
test_data.reset()
predicted_class_indices=np.argmax(pred,axis=1)
cm = confusion_matrix(test_labels, predictions.argmax(axis=1))
错误:
AttributeError: 'list' object has no attribute 'argmax'
您的
predictions
显然是一个Python列表,并且列表没有argmax
属性;您需要使用Numpy函数argmax()
:相关问题 更多 >
编程相关推荐