batch_size = 50
epochs = 15
model.fit_generator(datagen.flow(x_train, y_train, batch_size=batch_size),
validation_data=(x_validation, y_validation),
epochs=epochs, verbose=1, workers=4,
callbacks=[LearningRateScheduler(lr_schedule)])
ValueError: `steps_per_epoch=None` is only valid for a generator based on the `keras.utils.Sequence` class. Please specify `steps_per_epoch` or use the `keras.utils.Sequence` class.
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?我尝试在 Pip install tensorflow 和 conda install tensorflow 中重新安装 Tensosflow。
原因是创建的对象datagen.flow不知道其大小,因此您应该指定它预期产生值的次数,您可以结合批量大小来计算该值。
假设您有 100 个训练点,并且想要使用 30 的批量大小。那么,每个 epoch 需要 4 个步骤,计算方式如下:
from math import ceil
n_points = len(X_train)
batch_size = 30
steps_per_epoch = ceil(n_points / batch_size)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4014 次 |
| 最近记录: |