【问题标题】:Tensorflow failing to run wide and deep network tutorialTensorflow 无法运行广泛而深入的网络教程
【发布时间】:2017-05-01 22:20:01
【问题描述】:

我成功安装了 Tensorflow 并运行了 convolutional.py 示例。 但是,当我运行示例 Wide and Deep net tutorial 时,出现以下错误

 % python wide_deep_tutorial.py                                                                                                                 
   Training data is downloaded to /tmp/tmpr3k3fwnc
   Test data is downloaded to /tmp/tmpzxhrdh00
   model directory = /tmp/tmpg_s1yutm
   WARNING:tensorflow:The default value of combiner will change from "sum" to "sqrtn" after 2016/11/01.
   WARNING:tensorflow:The default value of combiner will change from "sum" to "sqrtn" after 2016/11/01.
   WARNING:tensorflow:The default value of combiner will change from "sum" to "sqrtn" after 2016/11/01.
   WARNING:tensorflow:The default value of combiner will change from "sum" to "sqrtn" after 2016/11/01.
   WARNING:tensorflow:The default value of combiner will change from "sum" to "sqrtn" after 2016/11/01.
   WARNING:tensorflow:The default value of combiner will change from "sum" to "sqrtn" after 2016/11/01.
   WARNING:tensorflow:The default value of combiner will change from "sum" to "sqrtn" after 2016/11/01.
   WARNING:tensorflow:The default value of combiner will change from "sum" to "sqrtn" after 2016/11/01.
   WARNING:tensorflow:The default value of combiner will change from "sum" to "sqrtn" after 2016/11/01.
   WARNING:tensorflow:The default value of combiner will change from "mean" to "sqrtn" after 2016/11/01.
   WARNING:tensorflow:The default value of combiner will change from "mean" to "sqrtn" after 2016/11/01.
   WARNING:tensorflow:The default value of combiner will change from "mean" to "sqrtn" after 2016/11/01.
   WARNING:tensorflow:The default value of combiner will change from "mean" to "sqrtn" after 2016/11/01.
   WARNING:tensorflow:The default value of combiner will change from "mean" to "sqrtn" after 2016/11/01.
   WARNING:tensorflow:The default value of combiner will change from "mean" to "sqrtn" after 2016/11/01.
   WARNING:tensorflow:From    /home/eliethesaiyan/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/estimators/dnn_linear_combined.py:711 in fit.: calling BaseEstimator.fit (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
    Instructions for updating:
    Estimator is decoupled from Scikit Learn interface by moving into
    separate class SKCompat. Arguments x, y and batch_size are only
    available in the SKCompat class, Estimator will only accept input_fn.
    Example conversion:
      est = Estimator(...) -> est = SKCompat(Estimator(...))
    WARNING:tensorflow:From /home/eliethesaiyan/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/estimators/dnn_linear_combined.py:711 in fit.: calling BaseEstimator.fit (from tensorflow.contrib.learn.python.learn.estimators.estimator) with y is deprecated and will be removed after 2016-12-01.
    Instructions for updating:
    Estimator is decoupled from Scikit Learn interface by moving into
    separate class SKCompat. Arguments x, y and batch_size are only
    available in the SKCompat class, Estimator will only accept input_fn.
    Example conversion:
      est = Estimator(...) -> est = SKCompat(Estimator(...))
    WARNING:tensorflow:From /home/eliethesaiyan/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/estimators/dnn_linear_combined.py:711 in fit.: calling BaseEstimator.fit (from tensorflow.contrib.learn.python.learn.estimators.estimator) with batch_size is deprecated and will be removed after 2016-12-01.
    Instructions for updating:
    Estimator is decoupled from Scikit Learn interface by moving into
    separate class SKCompat. Arguments x, y and batch_size are only
    available in the SKCompat class, Estimator will only accept input_fn.
    Example conversion:
      est = Estimator(...) -> est = SKCompat(Estimator(...))
    Traceback (most recent call last):
      File "wide_deep_tutorial.py", line 208, in <module>
        tf.app.run()
      File "/home/eliethesaiyan/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 43, in run
        sys.exit(main(sys.argv[:1] + flags_passthrough))
      File "wide_deep_tutorial.py", line 204, in main
        train_and_eval()
      File "wide_deep_tutorial.py", line 197, in train_and_eval
        m.fit(input_fn=lambda: input_fn(df_train), steps=FLAGS.train_steps)
      File "/home/eliethesaiyan/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/estimators/dnn_linear_combined.py", line 711, in fit
        max_steps=max_steps)
      File "/home/eliethesaiyan/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/util/deprecation.py", line 191, in new_func
        return func(*args, **kwargs)
      File "/home/eliethesaiyan/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 355, in fit
        max_steps=max_steps)
      File "/home/eliethesaiyan/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 690, in _train_model
        features, labels = input_fn()
      File "wide_deep_tutorial.py", line 197, in <lambda>
        m.fit(input_fn=lambda: input_fn(df_train), steps=FLAGS.train_steps)
      File "wide_deep_tutorial.py", line 159, in input_fn
        for k in CATEGORICAL_COLUMNS}
      File "wide_deep_tutorial.py", line 159, in <dictcomp>
        for k in CATEGORICAL_COLUMNS}
    TypeError: __init__() got an unexpected keyword argument 'dense_shape'

similar 问题中提出的最多问题,有人建议在安装 tensorflow 后卸载 protobuf 并安装它,但对我来说没有帮助,如果有人能提供帮助,我将不胜感激。

【问题讨论】:

  • 尝试将dense_shape 替换为shape。我认为在 API 的未来版本中它会被称为 dense_shape
  • 成功了,我想如果我要使用dense_shape,我应该直接从github签出

标签: tensorflow pip anaconda python-3.5


【解决方案1】:

TL;DR:确保运行与已安装的 TensorFlow 版本相匹配的 wide_n_deep_tutorial.py 版本。例如,如果您安装了 TensorFlow 0.12,则可以下载version from the r0.12 branch

文件 wide_n_deep_tutorial.py 在 TensorFlow 的 master 分支中是 recently changed,以反映 API 的变化(如 kempy points out 在他们的评论中,tf.SparseTensor.shapenexttf.SparseTensor.dense_shape /em> 释放)。

【讨论】:

  • 你说得对,是版本问题,我会留意下一个版本
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-12-14
  • 2016-12-20
  • 1970-01-01
  • 2016-02-10
  • 1970-01-01
  • 2019-12-03
相关资源
最近更新 更多