关于自定义模型(estimator)的使用介绍,下面文章里写的很详细,不再重复。
https://blog.csdn.net/amao1998/article/details/80202777
关于自定义模型函数的参数问题,之前一直不是很懂,原因是固定参数。
看了下Estimator的代码,里面会自动解释赋值。
def model_fn(
features, # 本批次的特征数据
labels, # 本批次的标记数据
mode, # tf.estimator.ModeKeys的一个实例,用以表示是要训练,评估,还是预测
params): # 模型额外参数
另外,
现在的Tensorflow有两个Estimator的API,功能类似,一直有疑惑,终于查到,tf.contrib.learn.Estimator为不推荐使用,以后的版本里应该会废除掉。
tf.contrib.learn.Estimator
tf.estimator.Estimator
参考 :https://www.tensorflow.org/guide/estimators
Note: TensorFlow also includes a deprecated Estimator class at tf.contrib.learn.Estimator, which you should not use.