错误详情:
ValueError: validation_steps=None
is only valid for a generator based on the keras.utils.Sequence
class. Please specify validation_steps
or use the keras.utils.Sequence
class.
使用数据:traffic_sign
代码部分:
history = model.fit_generator(
train_datagen,
validation_data = val_datagen,
epochs = config.epochs,
verbose = 1,
callbacks = callbacks,
steps_per_epoch=len(train_data_lists) // config.batch_size,
validation_steps=len(val_data_lists) // config.batch_size
)
问题分析:
- 验证集的数据量太小,除以批次后趋近于0
搜集到两种解决方案
方案(1)
修改计算validation_step的方法
validation_steps=len(val_data_lists) // config.batch_size
# 替换为
validation_steps=val_data_lists.shape[0] / config.batch_size
方案(2)
# 修改
batch_size = 1
# 待数据量变大后再调回较大size
2019.10.17 更新
在linux端跑没有出现报错!