gpt4 book ai didi

machine-learning - Keras 警告 on_batch_begin

转载 作者:行者123 更新时间:2023-11-30 08:36:12 25 4
gpt4 key购买 nike

当使用下面的回调 ResetStatesCallback 训练 rnn 模型时,我收到以下警告消息:

/var/venv/DSTL/lib/python3.4/site-packages/keras/callbacks.py:97: UserWarning: Method on_batch_begin() is slow compared to the batch update (0.791834). Check your callbacks. % delta_t_median)

from keras.callbacks import Callback
#Reset count every RESET_STATES_LENGTH
#RESET_STATES_LENGTH=8
class ResetStatesCallback(Callback):
def __init__(self):
self.counter = 0

def on_batch_begin(self, batch, logs={}):
if self.counter % RESET_STATES_LENGTH == 0:
self.model.reset_states()
self.counter += 1

为什么我会收到这条消息?我应该尝试一些方法来修复它吗?它真的会减慢我的训练速度吗?

最佳答案

参见https://github.com/fchollet/keras/issues/5008以获得解释。那里指出

You are running something like saving the model or rendering images after each batch and it is taking longer than the batches themselves.

因此,在运行时 Keras 似乎已确定您的回调比批处理本身慢。

关于machine-learning - Keras 警告 on_batch_begin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47575140/

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