TypeError:对于/:'NoneType'和'int'的不支持的操作数类型,对于extract_image_patches

时间:2017-07-21 03:57:15

标签: python tensorflow

我正在使用extract_image_patches作为具有动态尺寸的图像数据集。

我收到以下错误日志:

 array_grad.py", line 604, in _ExtractImagePatchesGrad     rows_out = int(ceil(rows_in / stride_r))
TypeError: unsupported operand type(s) for /: 'NoneType' and 'int'

我尝试使用

1) image.set_shape 方法

2)图片 resizing_using_crop_or_pad 以避免它,但错误仍然存​​在。

Update1 :以下是代码段

#######
#shape=[batch_size,height,width, target_size2

out_processed_model2 =tf.reshape(out_processed2, shape = [tf.shape(image_patch_tf2)[0], tf.shape(image_patch_tf2)[1], tf.shape(image_patch_tf2)[2], target_size2]) 

#PostProcessing

as0, as1, as2, as3, as4, as5= tf.split(out_processed_model2, target_size, 0)
out_model2_batch_to_depth = tf.concat([as0, as1, as2, as3, as4, as5],3)
#Model-3 Preprocessing

s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15,s16, s17, s18, s19= tf.split(out_model2_batch_to_depth , target_size2, 3)
A_3= tf.concat([s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15,s16, s17, s18, s19],1)
out_model2_depth_to_batch=tf.reshape(A_3, [tf.shape(image_patch_tf2)[0]*target_size2, tf.shape(image_patch_tf2)[1], tf.shape(image_patch_tf2)[2], 1])
############################Model -3#######################
stride_h3= 2
stride_w3 = 4
cell3 = 50
target_size3 = 80
input_size3 =stride_h3*stride_w3
image_patch_tf3 = tf.extract_image_patches(images = out_model2_depth_to_batch, ksizes = [1, stride_h3, stride_w3, 1], strides = [1, stride_h3, stride_w3, 1], rates = [1,1,1,1], padding="SAME", name="Extract_Image_Patches3")

1 个答案:

答案 0 :(得分:1)

根据错误,您尝试将NoneType用于rows_in。这可能意味着您设置此变量不正确。

错误消息会准确地告诉您发生了什么。 unsupported operand type(s) for /告诉您,导致错误的是在您的部门中发生的任何事情。之后它为您提供的两种类型NoneTypeint会告诉您与该操作一起使用的两个变量的类型。由于你不能将int除以int,因此会发生错误。