首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Keras ImageDataGenerator不同图像

Keras ImageDataGenerator不同图像
EN

Stack Overflow用户
提问于 2018-06-29 20:49:06
回答 1查看 96关注 0票数 0

我对Keras的ImageDataGenerator图像增强有困难。现在,我正试图在我的训练数据集中垂直翻转图像。X_batch是我的翻转图像数据集,X_train是我最初的训练数据集。

有人能解释为什么X_batch中的图像与X_train中的图像顺序不同吗?X_batch[0]应该是X_train[0]的翻转版本,而X_batch[0]是数据集中不同图像的翻转版本。

代码语言:javascript
复制
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)    

datagen = ImageDataGenerator(vertical_flip=True)
datagen.fit(X_train)

for X_batch, y_batch in datagen.flow(X_train, y_train):
    X_batch = X_batch.astype('uint8')

    plt.subplot(2, 1, 1)
    plt.imshow(X_batch[0]) // flipped image

    plt.subplot(2, 1, 2)
    plt.imshow(X_train[0]) // original image

    plt.show()
    break
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-06-29 21:29:44

根据Keras文档flow方法使用一个名为shuffle的参数,如果设置为True (默认情况下),则对数据进行洗牌,然后应用图像转换。如果不喜欢这种行为,可以将其设置为False

代码语言:javascript
复制
for X_batch, y_batch in datagen.flow(X_train, y_train, shuffle=False):
    ...
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51109215

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档