【Tensorflow】ValueError: The `kernel_size` argument must be a tuple of 1 integers. Received: [3, 3]

使用 tensorflow.contrib.slim 搭建卷积神经网络进行图片识别,图片inputs维度为[299,299,3],使用语句如下:

net = slim.conv2d(inputs, 32, [3, 3], stride=2, scope='Conv2d_la_3x3')
net = slim.conv2d(net, 32, [3, 3], scope='Conv2d_2a_3x3')
net = slim.conv2d(net, 64, [3, 3], padding='SAME', scope='Conv2d_2b_3x3')
net = slim.max_pool2d(net, [3, 3], stride=2, scope='Conv2d_3a_3x3')
net = slim.conv2d(net, 80, [1, 1], scope='Conv2d_3b_1x1')
net = slim.conv2d(net, 192, [3, 3], scope='Conv2d_4a_3x3')
net = slim.max_pool2d(net, [3, 3], stride=2, scope='Conv2d_5a_3x3')

报错信息如下:

net = slim.conv2d(inputs, 32, [3, 3], stride=2, scope='Conv2d_la_3x3')
……
ValueError: The `kernel_size` argument must be a tuple of 1 integers. Received: [3, 3]

出错原因:使用slim搭建卷积神经网络,需要以batch为单位进行数据输入,即inputs的维度应为[batch_size,299,299,3],batch_size即该batch图片的张数,例如有2000张图片,可以将其分为5个batch,每个batch400张图片,输入即为[400,299,299,3],关于batch的作用和用法请参考 

https://www.plob.org/article/13247.html  和

https://blog.csdn.net/oppo62258801/article/details/70767168

以下为第一篇博文截图:

【Tensorflow】ValueError: The `kernel_size` argument must be a tuple of 1 integers. Received: [3, 3]_第1张图片

 

你可能感兴趣的:(tensorflow,python,cnn,python)