Tensorflow报错:ValueError: Stride must be > 0, but got 0 for '...' with input shapes: [...], [...]

完整错误报错为:ValueError: Stride must be > 0, but got 0 for 'gradients/CON/de_conv8/conv2d_transpose_grad/Conv2D' (op: 'Conv2D') with input shapes: [96,16,16,128], [4,4,128,256].

tensorflow检测到我的strides输入为0,然而奇怪的是我并没有设置为0.

我的错误情景是:在对strides进行参数设置时设置为了[1, 1/2, 1/2, 1],意图进行通过反卷积进行upsampling。

后来在tensorflow的官网才查到


  • strides: A list of ints. The stride of the sliding window for each dimension of the input tensor.

    也就是说,strides这个参数内必须是整形数据。不能为小数,若为小数的话就会被raise ValueError报错为got 0 for stride!

这篇文章虽然内容很少,但因为这个问题卡了我一下午,并且网上搜不到相同的错误,所以打算记下来,方便他人的同时提醒自己不要再犯。同时我也重新设置了stride,使用反卷积达到了我想要的效果。

猜你喜欢

转载自blog.csdn.net/yyhhlancelot/article/details/83002983
今日推荐