Python 尝试从图像中提取补丁并获取;未实现错误:仅支持跨空间的ksizes”;

Python 尝试从图像中提取补丁并获取;未实现错误:仅支持跨空间的ksizes”;,python,tensorflow,tensorflow2.0,Python,Tensorflow,Tensorflow2.0,当我遇到以下错误时,我正试图通过4个补丁分割图像: UnimplementedError:仅支持跨空间的ksizes iterator=tf.compat.v1.data.make\u one\u shot\u迭代器(已解析的数据集) image,label=iterator.get_next() image\u height=image.shape[0] image\u width=image.shape[1] #因为预期的类型是(批次、高度、宽度、通道),所以我尝试扩展我的图像 #尺寸:(8

当我遇到以下错误时,我正试图通过4个补丁分割图像:

UnimplementedError:仅支持跨空间的ksizes

iterator=tf.compat.v1.data.make\u one\u shot\u迭代器(已解析的数据集)
image,label=iterator.get_next()
image\u height=image.shape[0]
image\u width=image.shape[1]
#因为预期的类型是(批次、高度、宽度、通道),所以我尝试扩展我的图像
#尺寸:(800344,3)至(1800344,3),但未解决错误。
#image=tf.展开(图像,0)
图像=列表(图像)
提取的修补程序=tf.image.提取修补程序(图像=图像,
大小=[1,int(0.25*图像高度),int(0.25*图像宽度),3],
步幅=[1,int(0.25*图像高度),int(0.25*图像宽度),3],
利率=[1,1,1,1],
padding=“相同”)
回溯:
---------------------------------------------------------------------------
未实现错误回溯(最近一次呼叫最后一次)
在()
17步幅=[1,int(0.25*图像高度),int(0.25*图像宽度),3],
18利率=[1,1,1,1],
--->19“相同”)
20
21
/用户/lucianoaraujo/anaconda2/lib/python2.7/site-packages/tensorflow\u core/python/ops/array\u ops.pyc在extract\u image\u patches\u v2中(图像、大小、步幅、速率、填充、名称)
4657   """
4658返回gen_阵列操作。提取图像块(图像、大小、步幅、速率、,
->4659(名称)
4660
4661
/用户/lucianoaraujo/anaconda2/lib/python2.7/site-packages/tensorflow\u core/python/ops/gen\u array\u ops.pyc在extract\u image\u补丁中(图像、大小、步幅、速率、填充、名称)
2542其他:
2543 message=e.message
->2544六。从(_核心。_状态_到_异常(例如代码、消息),无)
2545#将节点添加到TensorFlow图。
2546如果不是isinstance(ksizes,(列表,元组)):
/raise_from(value,from_value)中的Users/lucianoaraujo/anaconda2/lib/python2.7/site-packages/six.pyc
735其他:
736 def raise_from(值,from_值):
-->737提高价值
738
739
UnimplementedError:仅支持跨空间的ksizes。[Op:ExtractImagePatches]

经过进一步的研究,我可以通过以下方式进行管理:

images=列表(图像)
提取的修补程序=tf.image.提取修补程序(图像=图像,
大小=[1,int(0.25*图像高度),int(0.25*图像宽度),3],
步幅=[1,int(0.25*图像高度),int(0.25*图像宽度),3],
利率=[1,1,1,1],
padding=“相同”)
至:

image=tf.expand_dims(图像,0)
提取的修补程序=tf.image.提取修补程序(图像=图像,
大小=[1,int(0.5*图像高度),int(0.5*图像宽度),1],
步幅=[1,int(0.5*图像高度),int(0.5*图像宽度),1],
利率=[1,1,1,1],
padding=“相同”)
然后重塑以获得3通道图像:

patches=tf.重塑(提取的面片,[-1,int(0.5*图像高度),int(0.5*图像宽度),3])
---------------------------------------------------------------------------
UnimplementedError                        Traceback (most recent call last)
<ipython-input-64-23c2aff4c306> in <module>()
     17                                              strides=[1,int(0.25*image_height),int(0.25*image_width),3],
     18                                              rates=[1,1,1,1],
---> 19                                              padding="SAME")
     20 
     21 

/Users/lucianoaraujo/anaconda2/lib/python2.7/site-packages/tensorflow_core/python/ops/array_ops.pyc in extract_image_patches_v2(images, sizes, strides, rates, padding, name)
   4657   """
   4658   return gen_array_ops.extract_image_patches(images, sizes, strides, rates,
-> 4659                                              padding, name)
   4660 
   4661 

/Users/lucianoaraujo/anaconda2/lib/python2.7/site-packages/tensorflow_core/python/ops/gen_array_ops.pyc in extract_image_patches(images, ksizes, strides, rates, padding, name)
   2542       else:
   2543         message = e.message
-> 2544       _six.raise_from(_core._status_to_exception(e.code, message), None)
   2545   # Add nodes to the TensorFlow graph.
   2546   if not isinstance(ksizes, (list, tuple)):

/Users/lucianoaraujo/anaconda2/lib/python2.7/site-packages/six.pyc in raise_from(value, from_value)
    735 else:
    736     def raise_from(value, from_value):
--> 737         raise value
    738 
    739 

UnimplementedError: Only support ksizes across space. [Op:ExtractImagePatches]