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 没地定义这和调用啊

你可能感兴趣的:(Tensorflow)