【发布时间】:2021-06-24 03:35:46
【问题描述】:
我正在为 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'
【问题讨论】:
-
虽然这里的诊断很容易,但以后请发布完整的错误跟踪。另请注意,在错误之后出现的任何代码都与问题无关(从未执行),不应将其包含在此处,因为它只会造成不必要的混乱(已编辑)。
-
pred、predictions是从哪里来的?
标签: python tensorflow machine-learning keras classification