【问题标题】:Keras, ImageDataGenerator, cannot identify image fileKeras,ImageDataGenerator,无法识别图像文件
【发布时间】:2021-12-03 22:52:49
【问题描述】:

所以我显然在我的验证数据集上收到“无法识别图像文件 <_io.bytesio>”的错误。

我对此很陌生,有点迷茫。有什么明显的地方我做错了吗?

感谢大家的帮助。

image_generator = ImageDataGenerator(rescale=1/255, validation_split=0.2)    

train_dataset = image_generator.flow_from_directory(batch_size=32,
                                                 directory=PATH,
                                                 shuffle=True,
                                                 target_size=(224, 224), 
                                                 subset="training",
                                                 class_mode='categorical')

validation_dataset = image_generator.flow_from_directory(batch_size=32,
                                                 directory=PATH,
                                                 shuffle=True,
                                                 target_size=(224, 224), 
                                                 subset="validation",
                                                 class_mode='categorical')

model.fit_generator(
    train_dataset,
    samples_per_epoch=100,
    nb_epoch=10,
    validation_data=validation_dataset)

不确定这是否也与它有关。

【问题讨论】:

    标签: tensorflow keras


    【解决方案1】:

    model.fit() 中没有samples_per_epoch 或nb_epoch 等参数。

    查看link 以了解有关model.fit() 的更多说明。

    这些被命名为steps_per_epoch和epochs,如下所示:

    model.fit(train_dataset, 
              epochs=10, 
              steps_per_epoch=4, #(number of total images)/(batch_size) 
              validation_data=validation_dataset)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-26
      • 2017-09-11
      • 2015-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多