Keras flow_from_directory类索引 [英] Keras flow_from_directory class index

查看:82
本文介绍了Keras flow_from_directory类索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以前是手工制作的,但是现在我正在使用flow_from_directory用我自己的数据来训练我的网络.我只有一个问题.当我制作model.predict()时,如何知道我的预测索引0是标签类别dog,索引1是猫类别?

I used to make it manually, but i am using now flow_from_directory to train my network with my own data. I just have one question. When i make model.predict(), how can i know that my index 0 on predictions is for label category dog and index 1 is for category cats?

我正在使用的代码如下.

The code i am using is the following.

train_datagen = ImageDataGenerator(
    rescale=1./255,
    shear_range=0.2,
    zoom_range=0.2,
    horizontal_flip=True)

test_datagen = ImageDataGenerator(rescale=1./255)

train_generator = train_datagen.flow_from_directory(
        train_images_path,  
        target_size=(64, 64),  
        batch_size=batch_size)  


validation_generator = test_datagen.flow_from_directory(
        validate_images_path,
        target_size=(64, 64),
        batch_size=batch_size)
early_stopping = keras.callbacks.EarlyStopping(monitor='val_acc', min_delta=0, patience=3, verbose=1, mode='auto')
history = model.fit_generator(
        train_generator,
        steps_per_epoch=1700,
        epochs=epochs,
        verbose=1,
        callbacks=[early_stopping],
        validation_data=validation_generator,
        validation_steps=196
)

我想知道的是配对图像与地面真相标签.

What i wanted to know is the pair images vs ground truth label.

谢谢

推荐答案

您可以使用class_indices属性获取生成器生成的每个类的索引.

You can have the the index of each class generated by the generator with class_indices property.

print(validation_generator.class_indices)

简单...

这篇关于Keras flow_from_directory类索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆