只需尝试在Centos 7计算机上运行未经修改的Reference教程。我有yum update
机器。安装python3.6,从github中提取教程,下载并解压缩样本数据。其他教程运行。然后我跑:
python3.6 ptb_word_lm.py --data_path=simple-examples/data/
返回:
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'
作为总NOOB,我完全陷入了困境!有人可以帮忙吗?
答案 0 :(得分:1)
根据上述问题的评论,我安装了TensorFlow 1.0.0rc1
。我使用了pip3.6
,但是当我在Centos上时,OS Setup guide没有解决它,所以我不得不尝试每次下载:
(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
因此RHEL/Centos
的正确网址为:tensorflow-1.0.0rc1-cp36-cp36m-linux_x86_64.whl
。运行以下命令验证升级:
(tensorflow) [tensorflow]# python3.6 -c 'import tensorflow as tf; print(tf.__version__)'
1.0.0-rc1
现在再次运行教程,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'
原来两个tensorflow API发生了变化:
concat_v2
消失,只需更换:concat
scalar_summary
已重命名为:summary.scalar
。 ptb_word_lm.py 修改ptb_word_lm.py
以进行上述两项更改,现在教程应该正确运行!