Tensorflow 中earlystopping的使用

 参考该文章 https://blog.csdn.net/zongza/article/details/85017351

报错

Key signal_early_stopping/STOP not found in checkpoint
 RestoreV2[dtypes=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, ..., DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_INT64, DT_BOOL], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2/tensor_names, save/RestoreV2/shape_and_slices)]]

参考官方文档 进行调整  stop_if_no_decrease_hook

 

```python
 estimator = ...
 # Hook to stop training if loss does not decrease in over 100000 steps.
 hook = early_stopping.stop_if_no_decrease_hook(estimator, "loss", 100000)
 train_spec = tf.estimator.TrainSpec(..., hooks=[hook])
 tf.estimator.train_and_evaluate(estimator, train_spec, ...)
 ```

1.train_spec = tf.estimator.TrainSpec   而不是链接文章中的 model.train

2. 官方未说加eval_spec 定义 eval_spec 验证  eval_spec = tf.estimator.EvalSpec

3.tf.estimator.train_and_evaluate(model,train_spec,...) 加上eval_spec 后 可正常使用了

 

目前报Key signal_early_stopping/STOP not found in checkpoint    仍在解决中。。。。。

    最近升级  到tf 1.15 后  仍然报错 ,后来搜索,

参看keras 中

   checkpoint = CustomModelCheckpoint(
        model_to_save   = model_to_save,
        filepath        = saved_weights_name,# + '{epoch:02d}.h5', 
        monitor         = 'loss', 
        verbose         = 1, 
        save_best_only  = True, 
        mode            = 'min', 
        period          = 1
    )  

 这tf 没地定义这和调用啊

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值