小编may*_*_sa的帖子

在 Keras 中构建数据时如何使用 repeat() 函数?

我正在对猫和狗的数据集训练二元分类器:
总数据集:10000 张图像
训练数据集:8000 张图像
验证/测试数据集:2000 张图像

Jupyter 笔记本代码:

# Part 2 - Fitting the CNN to the images
train_datagen = ImageDataGenerator(rescale = 1./255,
                                   shear_range = 0.2,
                                   zoom_range = 0.2,
                                   horizontal_flip = True)

test_datagen = ImageDataGenerator(rescale = 1./255)

training_set = train_datagen.flow_from_directory('dataset/training_set',
                                                 target_size = (64, 64),
                                                 batch_size = 32,
                                                 class_mode = 'binary')

test_set = test_datagen.flow_from_directory('dataset/test_set',
                                            target_size = (64, 64),
                                            batch_size = 32,
                                            class_mode = 'binary')

history = model.fit_generator(training_set,
                              steps_per_epoch=8000,
                              epochs=25,
                              validation_data=test_set,
                              validation_steps=2000)
Run Code Online (Sandbox Code Playgroud)

我在 CPU 上训练它没有问题,但是当我在 GPU 上运行时,它抛出了这个错误:

Found 8000 images belonging …
Run Code Online (Sandbox Code Playgroud)

deep-learning keras tensorflow image-preprocessing

10
推荐指数
1
解决办法
1万
查看次数