gpt4 book ai didi

python - 在 keras fit_generator() 中未调用 on_epoch_end()

转载 作者:行者123 更新时间:2023-12-03 16:22:22 24 4
gpt4 key购买 nike

我关注了 this tutorial使用 fit_generator() 即时生成数据Keras 方法,用于训练我的神经网络模型。

我使用 keras.utils.Sequence 创建了一个生成器类(class)。调用fit_generator()是:

history = model.fit_generator(generator=EVDSSequence(images_train, TRAIN_BATCH_SIZE, INPUT_IMG_DIR, INPUT_JSON_DIR, SPLIT_CHAR, sizeArray, NCHW, shuffle=True),
steps_per_epoch=None, epochs=EPOCHS,
validation_data=EVDSSequence(images_valid, VALID_BATCH_SIZE, INPUT_IMG_DIR, INPUT_JSON_DIR, SPLIT_CHAR, sizeArray, NCHW, shuffle=True),
validation_steps=None,
callbacks=callbacksList, verbose=1,
workers=0, max_queue_size=1, use_multiprocessing=False)
steps_per_epochNone ,因此每个 epoch 的步数由 Keras __len()__ 计算得出方法。

正如上面的链接所说:

Here, the method on_epoch_end is triggered once at the very beginning as well as at the end of each epoch. If the shuffle parameter is set to True, we will get a new order of exploration at each pass (or just keep a linear exploration scheme otherwise).



我的问题是 on_epoch_end()方法仅在最开始时调用,而不会在每个 epoch 结束时调用。
因此,在每个时期,批次顺序始终相同。

我尝试使用 np.ceil而不是 np.floor__len__()方法,但没有成功。

你知道为什么 on_epoch_end不是在每个纪元结束时调用?您能告诉我在每个时代结束时(或开始时)调整批次顺序的任何解决方法吗?

非常感谢!

最佳答案

我遇到了同样的问题。我不知道为什么会发生这种情况,但有一种方法可以解决:调用 on_epoch_end()__len__() , 自 __len__()每个纪元都会被调用。

关于python - 在 keras fit_generator() 中未调用 on_epoch_end(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59645556/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com