本文介绍了TensorFlow中的tf.estimator.Estimator和tf.contrib.learn.Estimator有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几个月前,我使用了TensorFlow的tf.contrib.learn.DNNRegressor API,发现使用起来非常方便.最近几个月,我没有跟上TensorFlow的发展.现在,我有一个项目,我想再次使用Regressor,但是可以对DNNRegressor提供的实际模型进行更多控制.据我所见,Estimator API使用model_fn参数对此提供了支持.

Some months ago, I used the tf.contrib.learn.DNNRegressor API from TensorFlow, which I found very convenient to use. I didn't keep up with the development of TensorFlow the last few months. Now I have a project where I want to use a Regressor again, but with more control over the actual model as provided by DNNRegressor. As far as I can see, this is supported by the Estimator API using the model_fn parameter.

但是TensorFlow API中有两个Estimator:

But there are two Estimators in the TensorFlow API:

  • tf.contrib.learn.Estimator
  • tf.estimator.Estimator
  • tf.contrib.learn.Estimator
  • tf.estimator.Estimator

两者都提供了相似的API,但是用法却有些许不同.为什么会有两种不同的实现方式,并且有理由更喜欢一种实现方式?

Both provide a similar API, but are nevertheless slightly different in their usage. Why are there two different implementations and are there reasons to prefer one?

不幸的是,我在TensorFlow文档或使用哪种方法的指南中找不到任何区别.实际上,在TensorFlow教程中进行操作会产生很多警告,因为某些接口显然已更改(而不是xy参数,input_fn参数等等).

Unfortunately, I can't find any differences in the TensorFlow documentation or a guide when to use which of both. Actually, working through the TensorFlow tutorials produced a lot of warnings as some of the interfaces apparently have changed (instead of the x,y parameter, the input_fn parameter et cetera).

推荐答案

我想知道同样的事情,不能给出确切的答案,但是我有一些有根据的猜测可能对您有所帮助:

I wondered the same and cannot give a definitive answer, but I have a few educated guesses that might help you:

tf.estimator.Estimator与返回tf.estimator.EstimatorSpec的模型函数一起,似乎是最新示例中使用的最新函数,也是新代码中使用的模型函数.

It seems that tf.estimator.Estimator together with a model function that returns tf.estimator.EstimatorSpec is the most current one that is used in the newer examples and the one to be used in new code.

我现在的猜测是tf.contrib.learn.Estimator是一个早期的原型,已被tf.estimator.Estimator取代.根据文档,tf.contrib中的所有内容都是不稳定的API,可以随时更改,并且tf.estimator模块似乎是从tf.contrib.learn模块演变"的稳定API.我假设作者只是忘记将tf.contrib.learn.Estimator标记为已弃用,并且尚未将其删除,因此现有代码不会中断.

My guess now is that the tf.contrib.learn.Estimator is an early prototype that got replaced by the tf.estimator.Estimator. According to the docs everything in tf.contrib is unstable API that may change at any time and it looks like the tf.estimator module is the stable API that "evolved" from the tf.contrib.learn module. I assume that the authors just forgot to mark tf.contrib.learn.Estimator as deprecated and that it wasn't removed yet so existing code won't break.

这篇关于TensorFlow中的tf.estimator.Estimator和tf.contrib.learn.Estimator有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 21:22