简体   繁体   English

keras ImageDataGenerator目标数据

[英]keras ImageDataGenerator Target data

According to this page we can build a generator using the ImageDataGenerator class (and flow_from_directory method) that we can pass to model.fit_generator method in keras; 根据页面,我们可以使用ImageDataGenerator类(和flow_from_directory方法)构建生成器,并将其传递给keras中的model.fit_generator方法。 like this: 像这样:

train_datagen = ImageDataGenerator(rescale=1./255)

train_generator = train_datagen.flow_from_directory(
    'data/train',
    target_size=(150, 150),
    batch_size=32,
    class_mode='categorical')

model.fit_generator(
    train_generator,
    steps_per_epoch=2000,
    epochs=50)

But in the flow_from_directory method it only get the images for training from the directory and not the target labels because, while in normal model.fit method you pass the target data as a parameter, model.fit_generator accept only the generator of the training images; 但是在flow_from_directory方法中,它仅从目录而不是目标标签中获取用于训练的图像,因为在正常的model.fit方法中,您将目标数据作为参数传递, model.fit_generator仅接受训练图像的生成器; so where does it takes the expected output ? 那么预期的输出在哪里呢?

flow_from_dictionary表示“每个类应包含一个子目录”,这是因为子目录的名称将是该类的标签,因此,如果要在适当的标签目录中包含猫和狗的图片,则标签应为狗和猫,这很可能是您要寻找的东西,我记得使用了这样的功能,如果它改变了,我什么也不能说

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM