1 TensorFlow版本问题
# 报错信息
early_stopping_hook = tf.contrib.estimator.stop_if_no_decrease_hook(
AttributeError: module 'tensorflow.contrib.estimator' has no attribute 'stop_if_no_decrease_hook'
查看了本机的 tf版本发现是1.14,程序源码的版本是1.11 。查找了tensorflow的文档,发现 stop_if_no_decrease_hook 这个函数换位置了,不在这个 tensorflow.contrib.estimator 里面
在1.14版本中 应该是
tf.estimator.experimental.stop_if_no_decrease_hook
2 安装tensorflow-gpu版本
在GPU上训练模型比CPU快太多倍了,所以一定安装tensorflow-gpu版本!
# 建议用conda安装,这样不用手动安装对应版本的cudnn和cuda
conda install tensorflow-gpu==1.14.0