gpt4 book ai didi

python - Keras 提前停止回调错误,val_loss 指标不可用

转载 作者:太空狗 更新时间:2023-10-30 02:01:30 24 4
gpt4 key购买 nike

我正在训练 Keras(Tensorflow 后端,Python,在 MacBook 上),并且在 fit_generator 函数的提前停止回调中遇到错误。错误如下:

RuntimeWarning: Early stopping conditioned on metric `val_loss` which is not available. Available metrics are:
(self.monitor, ','.join(list(logs.keys()))),
RuntimeWarning: Can save best model only with val_acc available, skipping.

'skipping.' % (self.monitor), RuntimeWarning
[local-dir]/lib/python3.6/site-packages/keras/callbacks.py:497: RuntimeWarning: Early stopping conditioned on metric `val_loss` which is not available. Available metrics are:
(self.monitor, ','.join(list(logs.keys()))), RuntimeWarning
[local-dir]/lib/python3.6/site-packages/keras/callbacks.py:406: RuntimeWarning: Can save best model only with val_acc available, skipping.
'skipping.' % (self.monitor), RuntimeWarning)
Traceback (most recent call last):
:
[my-code]
:
File "[local-dir]/lib/python3.6/site-packages/keras/legacy/interfaces.py", line 91, in wrapper
return func(*args, **kwargs)
File "[local-dir]/lib/python3.6/site-packages/keras/engine/training.py", line 2213, in fit_generator
callbacks.on_epoch_end(epoch, epoch_logs)
File "[local-dir]/lib/python3.6/site-packages/keras/callbacks.py", line 76, in on_epoch_end
callback.on_epoch_end(epoch, logs)
File "[local-dir]/lib/python3.6/site-packages/keras/callbacks.py", line 310, in on_epoch_end
self.progbar.update(self.seen, self.log_values, force=True)
AttributeError: 'ProgbarLogger' object has no attribute 'log_values'

我的代码如下(看起来没问题):

:
ES = EarlyStopping(monitor="val_loss", min_delta=0.001, patience=3, mode="min", verbose=1)
:
self.model.fit_generator(
generator = train_batch,
validation_data = valid_batch,
validation_steps = validation_steps,
steps_per_epoch = steps_per_epoch,
epochs = epochs,
callbacks = [ES],
verbose = 1,
workers = 3,
max_queue_size = 8)

错误消息似乎与提前停止回调有关,但回调看起来正常。该错误还指出 val_loss 不合适,但我不确定为什么……关于此的另一件不寻常的事情是该错误仅在我使用较小的数据集时发生。

感谢任何帮助。

最佳答案

如果错误仅在您使用较小的数据集时出现,则您很可能使用的数据集小到验证集中没有单个样本。

因此它无法计算验证损失。

关于python - Keras 提前停止回调错误,val_loss 指标不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49035200/

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