问答详情
源自:3-4 TensorFlow结合mnist进行卷积模型训练(1)

运行convolutional.py报错

  File "D:\Python_The second stage\mnist\model.py", line 14, in conv2b

    return tf.nn.conv2d([1,1,1,1],padding="SAME")

TypeError: conv2d() missing 2 required positional arguments: 'filter' and 'strides'

以上是运行convolutional.py报错

def convolutional(x,keep_prob):
    def conv2b(x,W):
        return tf.nn.conv2d([1,1,1,1],padding="SAME")
    def max_pool_2x2(x):
        return tf.nn.max_pool(x,ksize=[1,2,2,1],strides=[1,2,2,1],padding="SAME")
    def weight_variable(shape):
        initial=tf.truncated_normal(shape,stddev=0.1)
        return tf.Variable(initial)
    def bias_variable(shape):
        initial=tf.constant(0.1,shape=shape)
        return tf.Variable(initial)

model.py代码和你一样

是什么原因?



提问者:诺言14 2018-09-27 20:25

个回答

  • qq_莫非
    2019-09-29 13:34:27

    代码参考这个链接https://www.cnblogs.com/Ph-one/p/9074706.html

  • 明台皓轩
    2018-11-25 21:32:10

    TypeError: conv2d() missing 2 required positional arguments: 'filter' and 'strides'

    我也是这个问题

  • 可乐__________
    2018-09-29 14:21:16

    def conv2d(x, W):

        return tf.nn.conv2d(x, W, [1, 1, 1, 1], padding='SAME')


  • 可乐__________
    2018-09-29 14:17:22

    TypeError: conv2d() missing 2 required positional arguments: 'filter' and 'strides'   我也是回头来检查代码的  囧

  • Mr_Ricky
    2018-09-28 09:34:17

    根据你的提示,是缺少了两个参数,你看下应该是少加了什么代码