简体   繁体   English

从Tensorflow运行RNN教程的TypeError

[英]TypeError running RNN tutorial from Tensorflow

Simply trying to run the unmodified RNN Tensorflow tutorial on a Centos 7 machine. 只需尝试在Centos 7机器上运行未经修改的RNN Tensorflow教程。 I have yum update d the machine. 我有yum update机器。 Installed python3.6, pulled the tutorial from github, downloaded and untarred the sample data. 安装python3.6,从github中提取教程,下载并解压缩样本数据。 Other tutorials run. 其他教程运行。 Then I run: 然后我跑:

python3.6 ptb_word_lm.py --data_path=simple-examples/data/

Which returns: 哪个回报:

Traceback (most recent call last):
  File "ptb_word_lm.py", line 374, in <module>
    tf.app.run()
  File "/usr/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 43, in run
    sys.exit(main(sys.argv[:1] + flags_passthrough))
  File "ptb_word_lm.py", line 334, in main
    train_input = PTBInput(config=config, data=train_data, name="TrainInput")
  File "ptb_word_lm.py", line 94, in __init__
    data, batch_size, num_steps, name=name)
  File "/root/tensorflow/models/tutorials/rnn/ptb/reader.py", line 117, in ptb_producer
    [batch_size, (i + 1) * num_steps])
TypeError: strided_slice() missing 1 required positional argument: 'strides'

As a total NOOB, I am completely stuck! 作为一个总NOOB,我完全卡住了! Can anyone help? 有人可以帮忙吗?

Per the comment on the question above, I installed TensorFlow 1.0.0rc1 . 根据上述问题的评论,我安装了TensorFlow 1.0.0rc1 I used pip3.6 , but as I was on Centos, the OS Setup guide doesn't address it, so I had to try each download: 我使用了pip3.6 ,但是当我在Centos上时, 操作系统设置指南没有解决它,所以我不得不尝试每次下载:

(tensorflow) [tensorflow]# export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.0.0rc1-cp35-cp35m-linux_x86_64.whl
(tensorflow) [tensorflow]# pip3.6 install --upgrade $TF_BINARY_URL
tensorflow-1.0.0rc1-cp35-cp35m-linux_x86_64.whl is not a supported wheel on this platform.
(tensorflow) [tensorflow]# export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.0.0rc1-cp34-cp34m-linux_x86_64.whl
(tensorflow) [tensorflow]# pip3.6 install --upgrade $TF_BINARY_URL
tensorflow-1.0.0rc1-cp34-cp34m-linux_x86_64.whl is not a supported wheel on this platform.
(tensorflow) [tensorflow]# export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.0.0rc1-cp27-none-linux_x86_64.whl
(tensorflow) [tensorflow]# pip3.6 install --upgrade $TF_BINARY_URL
tensorflow-1.0.0rc1-cp27-none-linux_x86_64.whl is not a supported wheel on this platform.
(tensorflow) [tensorflow]# export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.0.0rc1-cp33-cp33m-linux_x86_64.whl
(tensorflow) [tensorflow]# pip3.6 install --upgrade $TF_BINARY_URL
tensorflow-1.0.0rc1-cp33-cp33m-linux_x86_64.whl is not a supported wheel on this platform.
(tensorflow) [tensorflow]# export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.0.0rc1-cp36-cp36m-linux_x86_64.whl
(tensorflow) [tensorflow]# pip3.6 install --upgrade $TF_BINARY_URL
    Collecting tensorflow==1.0.0rc1 from https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.0.0rc1-cp36-cp36m-linux_x86_64.whl
  Downloading https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.0.0rc1-cp36-cp36m-linux_x86_64.whl (43.5MB)
    100% |████████████████████████████████| 43.5MB 28kB/s 
Requirement already up-to-date: six>=1.10.0 in /usr/lib/python3.6/site-packages (from tensorflow==1.0.0rc1)
Requirement already up-to-date: wheel>=0.26 in /usr/lib/python3.6/site-packages (from tensorflow==1.0.0rc1)
Requirement already up-to-date: protobuf>=3.1.0 in /usr/lib/python3.6/site-packages (from tensorflow==1.0.0rc1)
Requirement already up-to-date: numpy>=1.11.0 in /usr/lib64/python3.6/site-packages (from tensorflow==1.0.0rc1)
Requirement already up-to-date: setuptools in /usr/lib/python3.6/site-packages (from protobuf>=3.1.0->tensorflow==1.0.0rc1)
Requirement already up-to-date: packaging>=16.8 in /usr/lib/python3.6/site-packages (from setuptools->protobuf>=3.1.0->tensorflow==1.0.0rc1)
Requirement already up-to-date: appdirs>=1.4.0 in /usr/lib/python3.6/site-packages (from setuptools->protobuf>=3.1.0->tensorflow==1.0.0rc1)
Requirement already up-to-date: pyparsing in /usr/lib/python3.6/site-packages (from packaging>=16.8->setuptools->protobuf>=3.1.0->tensorflow==1.0.0rc1)
Installing collected packages: tensorflow
  Found existing installation: tensorflow 0.12.1
    Uninstalling tensorflow-0.12.1:
      Successfully uninstalled tensorflow-0.12.1
Successfully installed tensorflow-1.0.0rc1

So the correct URL for RHEL/Centos is: tensorflow-1.0.0rc1-cp36-cp36m-linux_x86_64.whl . 因此, RHEL/Centos的正确URL是: tensorflow-1.0.0rc1-cp36-cp36m-linux_x86_64.whl Verify your upgrade by running: 运行以下命令验证升级:

(tensorflow) [tensorflow]# python3.6 -c 'import tensorflow as tf; print(tf.__version__)'
1.0.0-rc1

Now run the tutorial again, the TypeError is gone, but is replaced by an AttributeError : 现在再次运行教程, TypeError消失了,但是被AttributeError取代:

(tensorflow) [tensorflow]# python3.6 ptb_word_lm.py --data_path=simple-examples/data/
Traceback (most recent call last):
  ...
  File "ptb_word_lm.py", line 149, in __init__
     output = tf.reshape(tf.concat_v2(outputs, 1), [-1, size])
AttributeError: module 'tensorflow' has no attribute 'concat_v2'

Turns out that TWO tensorflow APIs changed: 原来两个tensorflow API发生了变化:

  1. concat_v2 goes away and is replaced simply by: concat concat_v2消失了,简单地替换为: concat
  2. Likewise, scalar_summary has been renamed to: summary.scalar . 同样, scalar_summary已重命名为: summary.scalar There are 3 such references in ptb_word_lm.py ptb_word_lm.py中有3个这样的引用

Edit ptb_word_lm.py to make both of the changes above AND the tutorial should now run correctly for you! 编辑ptb_word_lm.py以进行上述两项更改,现在教程应该正确运行!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM