简体   繁体   English

输入的数据用完了; 中断训练

[英]input ran out of data; interrupting training

I am trying to train a model with the dataset consisting of 160 images (80 -cars, 80 -planes) using image data-augmentation generators on TensorFlow v2.1.我正在尝试使用 TensorFlow v2.1 上的图像数据增强生成器来训练 model 的数据集,该数据集包含 160 个图像(80 个汽车,80 个飞机)。 I am getting an error when I run the following code:运行以下代码时出现错误:

classifier.compile(optimizer='adam', loss='binary_crossentropy',
                   metrics=['accuracy'])
from keras.preprocessing.image import ImageDataGenerator
train_imagedata = ImageDataGenerator(rescale=1. / 255, shear_range=0.2,
        zoom_range=0.2, horizontal_flip=True)
test_imagedata = ImageDataGenerator(rescale=1. / 255)
training_set = \
    train_imagedata.flow_from_directory('data/training_set'
        , target_size=(64, 64), batch_size=32, class_mode='binary')
val_set = \
    test_imagedata.flow_from_directory('data/val_set'
        , target_size=(64, 64), batch_size=32, class_mode='binary')
history=classifier.fit(training_set, steps_per_epoch=30, epochs=30,
                         validation_data=val_set,
                         validation_steps=30)

The error is:错误是:

Found 160 images belonging to 2 classes.
Found 40 images belonging to 2 classes.
Epoch 1/30
 5/30 [====>.........................] - ETA: 5s - loss: 0.5002 - accuracy: 0.8313WARNING:tensorflow:Your input ran out of data; interrupting training. Make sure that your dataset or generator can generate at least `steps_per_epoch * epochs` batches (in this case, 900 batches). You may need to use the repeat() function when building your dataset.
WARNING:tensorflow:Your input ran out of data; interrupting training. Make sure that your dataset or generator can generate at least `steps_per_epoch * epochs` batches (in this case, 30 batches). You may need to use the repeat() function when building your dataset.
 5/30 [====>.........................] - 2s 416ms/step - loss: 0.5002 - accuracy: 0.8313 - val_loss: 1.6599 - val_accuracy: 0.5000

Please suggest what could be done here to rectify this error?请建议在这里可以做些什么来纠正这个错误? Thanks in Advance!提前致谢!

ImageDataGenerator has a default batch_size of 32. you asked to perform 30 steps per epoch, which means 30*32 images per epoch, but you have only 160 images, hence after 5 batches the training collapse. ImageDataGenerator 的默认batch_size为 32。您要求每个 epoch 执行 30 个步骤,这意味着每个 epoch 30*32 个图像,但您只有 160 个图像,因此在 5 个批次后训练崩溃。 you need to set steps_per_epoch to be floor(num_of_images / batch_size) .您需要将steps_per_epoch设置为floor(num_of_images / batch_size)

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

相关问题 警告:tensorflow:您的输入数据不足; 中断训练 - WARNING:tensorflow:Your input ran out of data; interrupting training 训练时出错:tensorflow:你的输入数据用完了; 中断训练 - Error while training: tensorflow:Your input ran out of data; interrupting training 'tf.data()' throwing 你的输入数据用完了; 中断训练 - 'tf.data()' throwing Your input ran out of data; interrupting training 您输入的数据不足; 中断训练。 确保您的数据集或生成器至少可以生成`steps_per_epoch - Your input ran out of data; interrupting training. Make sure that your dataset or generator can generate at least `steps_per_epoch 您输入的数据用完了; 中断训练。 确保您的数据集或生成器至少可以生成 `steps_per_epoch * epochs` 批次 - Your input ran out of data; interrupting training. Make sure that your dataset or generator can generate at least `steps_per_epoch * epochs` batches “WARNING:tensorflow:Your input run out of data”训练时出现错误 Keras Model - “WARNING:tensorflow:Your input ran out of data” Error appearing when training Keras Model 输入用完数据错误但数据在那里 - Input ran out of Data error but the data is there tensorflow:您的输入数据用完 - tensorflow:Your input ran out of data Tensorflow 输入生成器用完了数据 - Tensorflow input generator ran out of data EOFError:用尽输入 - EOFError: Ran out of input
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM