首页 > 解决方案 > tf.contrib.image.rotate() 导致错误 - 具有多个元素的数组的真值不明确。使用 a.any() 或 a.all()

问题描述

我正在尝试运行

zzz = tf.contrib.image.rotate(image, 0.0348, interpolation='NEAREST')

但得到错误:


ValueError Traceback (last last call last) in () 5 6 ----> 7 zzz = tf.contrib.image.rotate(image, 0.0348, interpolation='NEAREST') 8 9 # zz = []

/usr/local/lib/python3.6/dist-packages/tensorflow/contrib/image/python/ops/image_ops.py 在旋转(图像,角度,插值,名称) 88 图像,89 角度_to_projective_transforms(角度,图像高度,图像宽度), ---> 90 interpolation=interpolation) 91 如果 image_or_images.get_shape().ndims 为 None: 92 raise TypeError("image_or_images rank must be statically known")

/usr/local/lib/python3.6/dist-packages/tensorflow/contrib/image/python/ops/image_ops.py in transform(images, transforms, interpolation, output_shape, name) 273 如果 output_shape 为 None:274 output_shape = tensor_util.constant_value(--> 275 array_ops.shape(images)[1:3]) 或 array_ops.shape(images)[1:3] 276 277 output_shape = ops.convert_to_tensor(

ValueError:具有多个元素的数组的真值不明确。使用 a.any() 或 a.all()

我错过了什么?

更新:

我在谷歌合作上使用 Tensorfloe 1.12.0。运行下面的代码给出了同样的错误

image = np.zeros((50, 90, 3)); tf.contrib.image.rotate(image, .3)

急切的前任时会出现此错误消息。使用 tf.enable_eager_execution() 启用

标签: pythontensorflow

解决方案


推荐阅读