ValueError:形状(2,1)和()不兼容

时间:2017-05-10 20:03:00

标签: python python-3.x tensorflow windows-10 anaconda

我必须使用Tensorflow 0.11作为this code repo,这是我得到的错误:

(py35) E:\opensource_codes\gesture_recognition\hand3d-master>python run.py
Traceback (most recent call last):
  File "run.py", line 47, in <module>
    keypoints_scoremap_tf, keypoint_coord3d_tf = net.inference(image_tf, hand_side_tf, evaluation)
  File "E:\opensource_codes\gesture_recognition\hand3d-master\net.py", line 37, in inference
    hand_mask = single_obj_scoremap(hand_scoremap)
  File "E:\opensource_codes\gesture_recognition\hand3d-master\utils.py", line 246, in single_obj_scoremap
    max_loc = find_max_location(scoremap_fg)
  File "E:\opensource_codes\gesture_recognition\hand3d-master\utils.py", line 228, in find_max_location
    xy_loc.append(tf.concat(0, [x_loc, y_loc]))
  File "C:\Users\mona6\AppData\Local\conda\conda\envs\py35\lib\site-packages\tensorflow\python\ops\array_ops.py", line 1030, in concat
    ).assert_is_compatible_with(tensor_shape.scalar())
  File "C:\Users\mona6\AppData\Local\conda\conda\envs\py35\lib\site-packages\tensorflow\python\framework\tensor_shape.py", line 735, in assert_is_compatible_with
    raise ValueError("Shapes %s and %s are incompatible" % (self, other))
ValueError: Shapes (2, 1) and () are incompatible

(py35) E:\opensource_codes\gesture_recognition\hand3d-master>python
Python 3.5.3 |Continuum Analytics, Inc.| (default, Feb 22 2017, 21:28:42) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> tf.__version__
'1.1.0'
>>>

请建议修复。

错误似乎来自行xy_loc.append(tf.concat(0, [x_loc, y_loc]))

我想确保我有完全相同的Tensorflow颠覆,所以我这样做但仍然得到上述错误。

(py35) E:\opensource_codes\gesture_recognition\hand3d-master>pip install tensorflow==1.1.0rc0
Collecting tensorflow==1.1.0rc0
  Using cached tensorflow-1.1.0rc0-cp35-cp35m-win_amd64.whl
Requirement already satisfied: protobuf>=3.2.0 in c:\users\mona6\appdata\local\conda\conda\envs\py35\lib\site-packages (from tensorflow==1.1.0rc0)
Requirement already satisfied: six>=1.10.0 in c:\users\mona6\appdata\local\conda\conda\envs\py35\lib\site-packages (from tensorflow==1.1.0rc0)
Requirement already satisfied: werkzeug>=0.11.10 in c:\users\mona6\appdata\local\conda\conda\envs\py35\lib\site-packages (from tensorflow==1.1.0rc0)
Requirement already satisfied: wheel>=0.26 in c:\users\mona6\appdata\local\conda\conda\envs\py35\lib\site-packages (from tensorflow==1.1.0rc0)
Requirement already satisfied: numpy>=1.11.0 in c:\users\mona6\appdata\local\conda\conda\envs\py35\lib\site-packages (from tensorflow==1.1.0rc0)
Requirement already satisfied: setuptools in c:\users\mona6\appdata\local\conda\conda\envs\py35\lib\site-packages (from protobuf>=3.2.0->tensorflow==1.1.0rc0)
Requirement already satisfied: appdirs>=1.4.0 in c:\users\mona6\appdata\local\conda\conda\envs\py35\lib\site-packages (from setuptools->protobuf>=3.2.0->tensorflow==1.1.0rc0)
Requirement already satisfied: packaging>=16.8 in c:\users\mona6\appdata\local\conda\conda\envs\py35\lib\site-packages (from setuptools->protobuf>=3.2.0->tensorflow==1.1.0rc0)
Requirement already satisfied: pyparsing in c:\users\mona6\appdata\local\conda\conda\envs\py35\lib\site-packages (from packaging>=16.8->setuptools->protobuf>=3.2.0->tensorflow==1.1.0rc0)
Installing collected packages: tensorflow
  Found existing installation: tensorflow 1.1.0
    Uninstalling tensorflow-1.1.0:
      Successfully uninstalled tensorflow-1.1.0
Successfully installed tensorflow-1.1.0rc0

1 个答案:

答案 0 :(得分:0)

安装了tensorflow 0.12,代码完美无缺: enter image description here

(py35) E:\opensource_codes\gesture_recognition\hand3d-master>pip install tensorflow==1.2.0
Collecting tensorflow==1.2.0
  Could not find a version that satisfies the requirement tensorflow==1.2.0 (from versions: 0.12.0rc0, 0.12.0rc1, 0.12.0, 0.12.1, 1.0.0, 1.0.1, 1.1.0rc0, 1.1.0rc1, 1.1.0rc2, 1.1.0)
No matching distribution found for tensorflow==1.2.0

(py35) E:\opensource_codes\gesture_recognition\hand3d-master>pip install tensorflow==0.12.1
Collecting tensorflow==0.12.1
  Downloading tensorflow-0.12.1-cp35-cp35m-win_amd64.whl (13.7MB)
    100% |################################| 13.8MB 130kB/s
Requirement already satisfied: numpy>=1.11.0 in c:\users\mona6\appdata\local\conda\conda\envs\py35\lib\site-packages (from tensorflow==0.12.1)
Requirement already satisfied: protobuf>=3.1.0 in c:\users\mona6\appdata\local\conda\conda\envs\py35\lib\site-packages (from tensorflow==0.12.1)
Requirement already satisfied: six>=1.10.0 in c:\users\mona6\appdata\local\conda\conda\envs\py35\lib\site-packages (from tensorflow==0.12.1)
Requirement already satisfied: wheel>=0.26 in c:\users\mona6\appdata\local\conda\conda\envs\py35\lib\site-packages (from tensorflow==0.12.1)
Requirement already satisfied: setuptools in c:\users\mona6\appdata\local\conda\conda\envs\py35\lib\site-packages (from protobuf>=3.1.0->tensorflow==0.12.1)
Requirement already satisfied: packaging>=16.8 in c:\users\mona6\appdata\local\conda\conda\envs\py35\lib\site-packages (from setuptools->protobuf>=3.1.0->tensorflow==0.12.1)
Requirement already satisfied: appdirs>=1.4.0 in c:\users\mona6\appdata\local\conda\conda\envs\py35\lib\site-packages (from setuptools->protobuf>=3.1.0->tensorflow==0.12.1)
Requirement already satisfied: pyparsing in c:\users\mona6\appdata\local\conda\conda\envs\py35\lib\site-packages (from packaging>=16.8->setuptools->protobuf>=3.1.0->tensorflow==0.12.1)
Installing collected packages: tensorflow
  Found existing installation: tensorflow 1.1.0rc0
    Uninstalling tensorflow-1.1.0rc0:
      Successfully uninstalled tensorflow-1.1.0rc0
Successfully installed tensorflow-0.12.1

(py35) E:\opensource_codes\gesture_recognition\hand3d-master>python run.py