ValueError:形状(2,1)和()不兼容 [英] ValueError: Shapes (2, 1) and () are incompatible

查看:111
本文介绍了ValueError:形状(2,1)和()不兼容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须对

 (py35)E:\ opensource_codes \ gesture_recognition \ hand3d-master> pip install tensorflow == 1.2.0收集张量流== 1.2.0找不到满足tensorflow == 1.2.0的版本(来自版本: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)找不到与tensorflow == 1.2.0匹配的分布(py35)E:\ opensource_codes \ gesture_recognition \ hand3d-master> pip install tensorflow == 0.12.1收集张量流== 0.12.1下载tensorflow-0.12.1-cp35-cp35m-win_amd64.whl(13.7MB)100%| ############################## ||13.8MB 130kB/秒已经满足要求:c:\ users \ mona6 \ appdata \ local \ conda \ conda \ envs \ py35 \ lib \ site-packages中的numpy> = 1.11.0(来自tensorflow == 0.12.1)已经满足要求:c:\ users \ mona6 \ appdata \ local \ conda \ conda \ envs \ py35 \ lib \ site-packages中的protobuf> = 3.1.0(来自tensorflow == 0.12.1)已经满足要求:c> = 1.10.0,位于c:\ users \ mona6 \ appdata \ local \ conda \ conda \ envs \ py35 \ lib \ site-packages中(来自tensorflow == 0.12.1)已满足要求:c:\ users \ mona6 \ appdata \ local \ conda \ conda \ envs \ py35 \ lib \ site-packages中的wheel> = 0.26(来自tensorflow == 0.12.1)已经满足要求:c:\ users \ mona6 \ appdata \ local \ conda \ conda \ envs \ py35 \ lib \ site-packages中的setuptools(来自protobuf> = 3.1.0-> tensorflow == 0.12.1)已经满足的要求:在c:\ users \ mona6 \ appdata \ local \ conda \ conda \ envs \ py35 \ lib \ site-packages中打包> = 16.8(来自setuptools-> protobuf> = 3.1.0-> tensorflow == 0.12.1)已经满足的要求:c:\ users \ mona6 \ appdata \ local \ conda \ conda \ envs \ py35 \ lib \ site-packages中的appdirs = 1.4.0(来自setuptools-> protobuf> = 3.1.0->tensorflow = = 0.12.1)已经满足的要求:在c:\ users \ mona6 \ appdata \ local \ conda \ conda \ envs \ py35 \ lib \ site-packages中进行解析(来自包装> = 16.8-> setuptools-> protobuf> = 3.1.0-> tensorflow == 0.12.1)安装收集的软件包:tensorflow找到现有安装:tensorflow 1.1.0rc0卸载tensorflow-1.1.0rc0:已成功卸载tensorflow-1.1.0rc0成功安装tensorflow-0.12.1(py35)E:\ opensource_codes \ gesture_recognition \ hand3d-master> python run.py 

I have to use Tensorflow 0.11 for this code repo and this is the error I get:

(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'
>>>

Please suggest fixes.

The error seems to stem from the line xy_loc.append(tf.concat(0, [x_loc, y_loc]))

I wanted to make sure that I have the same exact subversion of Tensorflow so I did so but still get the above error.

(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

解决方案

Installed the tensorflow 0.12 and the code worked perfectly with no change:

(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

这篇关于ValueError:形状(2,1)和()不兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆