我想用tf.image.resize_image_with_crop_or_pad
裁剪输入图像的一部分。但是出现了一个错误:ValueError: 'image' must be fully defined
。我检查了添加的Why do I get ValueError('\'image\' must be fully defined.') when transforming image in Tensorflow?,但它也不能工作。
我列出我的代码和错误如下:
example = tf.image.decode_png(file_contents, channels=3)
example.set_shape = ([256,256,3])
crop_image = tf.image.resize_image_with_crop_or_pad(example, crop_size, crop_size)
错误:
^{pr2}$我不知道为什么错误会出现,即使我设置了一定的形状图像。 但是,我测试代码如下:
example = tf.image.decode_png(file_contents, channels=3)
example = tf.reshape(example, [256,256,3])
crop_image = tf.image.resize_image_with_crop_or_pad(example, crop_size, crop_size)
它起作用了。我认为整形到同一个形状不会改变张量值的顺序,对吗?也许这就是解决办法。在
问题出在线路上
您将重写方法
tf.Tensor.set_shape
,并将其设置为一个值。在
^{2}$set_shape
是一个方法,因此必须正确调用它:在那之后,你的代码就可以工作了。在
是的,你说得对
相关问题 更多 >
编程相关推荐