gpt4 book ai didi

python - Keras:方法 on_batch_end() 很慢但我没有回调?

转载 作者:行者123 更新时间:2023-11-28 19:03:00 26 4
gpt4 key购买 nike

Keras 刚刚警告我:

UserWarning: Method on_batch_end() is slow compared to the batch update (0.988304). Check your callbacks.

我的 keras 脚本中没有回调,但我正在使用 DataGenerator (keras.utils.Sequence)。这会是个问题吗?

对于DataGenerator,我实现了__init__()__len__()__getitem()__on_epoch_end 方法。

对于 on_epoch_end,我有:

def on_epoch_end(self):
"""
This method will be called between every epoch, so we can shuffle the
indexes here.
"""
self.indexes = np.arange(len(self.image_names))
if self.shuffle:
np.random.shuffle(self.indexes)

完整的调用栈如下:

Using TensorFlow backend. /var/lib/condor/execute/slot1/dir_30551/anaconda/envs/cellimage/lib/python3.6/site-packages/skimage/transform/_warps.py:84: UserWarning: The default mode, 'constant', will be changed to 'reflect' in skimage 0.15.

warn("The default mode, 'constant', will be changed to 'reflect' in " /var/lib/condor/execute/slot1/dir_30551/anaconda/envs/cellimage/lib/python3.6/site-packages/keras/callbacks.py:120: UserWarning: Method on_batch_end() is slow compared to the batch update (0.586719). Check your callbacks. % delta_t_median)

/var/lib/condor/execute/slot1/dir_30551/anaconda/envs/cellimage/lib/python3.6/site-packages/keras/callbacks.py:120: UserWarning: Method on_batch_end() is slow compared to the batch update (0.988304). Check your callbacks. % delta_t_median)

最佳答案

这可能与您的 verbose 设置有关。

我看到的是一样的。我相信这是因为我在调用 fit() 时有 verbose=1 - 即打印进度条和当前统计信息是一个批处理结束任务,它也需要长的。如果我设置仅在纪元结束时打印的 verbose=2 或根本不打印的 verbose=0 ,警告就会停止,这一假设得到了证据的支持。如果我增加批量大小,警告也会停止。

关于python - Keras:方法 on_batch_end() 很慢但我没有回调?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50469757/

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