首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TypeError: /的不受支持的操作数类型:“NoneType”和“int”,用于extract_image_patches

TypeError: /的不受支持的操作数类型:“NoneType”和“int”,用于extract_image_patches
EN

Stack Overflow用户
提问于 2017-07-21 03:57:15
回答 1查看 974关注 0票数 1

我使用extract_image_patches作为我的图像数据集,它具有动态维度。

我得到以下错误日志:

代码语言:javascript
复制
 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:下面是代码片段

代码语言:javascript
复制
#######
#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")
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-07-21 03:59:47

根据错误,您正在尝试将NoneType用于rows_in。这很可能意味着,不管您如何设置这个变量,都是不正确的。

错误信息准确地告诉您发生了什么。unsupported operand type(s) for /告诉您,无论是什么原因造成的错误正在发生在您的部门。它提供给您的两种类型之后,NoneTypeint告诉您与该操作一起使用的两个变量的类型。由于不能将任何一个除以int,因此会发生错误。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45228701

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档