TF2 对 LSTM 网络中的步数感到困惑

TF2 confused about step numbers in LSTM Network

我目前正在尝试使用我自己的数据集从 this 实施身份验证网络。

This is my colab notebook

它正在“工作”(数据集大小仍然太小,无法进行任何有意义的测试),但我对某些事情感到困惑。

输入的形状为 (482, 12, 128, 1)。 482个样本量,12个传感器,128为信号长度,1个通道

所以我希望有这样的东西:

Epoch 1/10
X/482 [===...

在训练中,或者 X/batch_size(我现在还没有指定)。

但它是 X/16。 现在 16 是 LSTM 的序列长度(我在一个序列的 LSTM 有 16 个输入,每个有 128 个值)

这是怎么回事?

当您调用 model.fit() 而不指定 batch_size 参数时,它默认为 32。

batch_size: Integer or None. Number of samples per gradient update. If unspecified, batch_size will default to 32. Do not specify the batch_size if your data is in the form of datasets, generators, or keras.utils.Sequence instances (since they generate batches).

如果将样本数分成 32 个批次,则需要 16 个批次(15 个完整批次,1 个部分批次)。

482/32 = 15.0625

因此需要 16 个批次才能完成 1 个 epoch,这就是为什么您看到进度为 X/16