參考該文章 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 沒地定義這和調用啊