steps_per_epoch 和 epochs 的设置如何影响 Keras 的训练结果?

How dose the setting of steps_per_epoch and epochs affect the training result in Keras?

我的生成器总是从我的数据集中随机生成两张图像,然后我使用这两个样本计算损失。假设我设置 steps_per_epoch=40epochs=5,如果我设置 steps_per_epoch=5epochs=40 有什么区别(我使用 Adam 作为我的优化器)?

epochs参数(也称为迭代)指的是整个训练数据的完整传递次数。 steps_per_epoch 参数指的是在一个时期内生成的批次数。因此我们有 steps_per_epoch = n_samples / batch_size.

例如,如果我们有 1000 个训练样本并且我们将 batch-size 设置为 10,那么我们有 steps_per_epoch = 1000 / 10 = 100epochs可以不考虑batch-size或者steps_per_epoch的值设置。

没有适用于所有场景的批量大小的确定值。通常,非常大的批量大小会减慢训练过程(即模型需要更多时间才能收敛到解决方案)并且非常小的批量大小可能无法很好地利用可用资源(即 GPU 和 CPU).通常的值包括 32、64、128、256、512(2 的幂有助于加快 GPU 内存分配)。此外, that concerns this issue which includes citations of relevant books and papers. Or take a look at this question 及其关于交叉验证的答案以获得更完整的批量大小定义。