对于猫狗图像的二进制分类,我的目录结构是 train_dir/cats 和 train_dir/dogs。
train_datagen = ImageDataGenerator(rescale=1/255)
train_generator = train_datagen.flow_from_directory(
'/train_dir/', # This is the source directory for training images
target_size=(300, 300), # All images will be resized to 150x150
batch_size=128,
# Since we use binary_crossentropy loss, we need binary labels
class_mode='binary')
model.predict(images, batch_size=10)
如何知道 model.predict() 的概率返回属于哪个类?是猫=1 还是狗=1?我在某处读到,对于多类分类,返回的概率按类名的字母顺序排列。但我认为二进制分类并非如此。