tensorflow1.X TypeError: __init__() got multiple values for argument ‘filters‘

1.错误详情

 File "E:\road_dection\yanyousan-yousan.ai-master\yousan.ai\computer_vision\projects\classification\tensorflow\lianxi\net.py", line 11, in simpleconv3
    conv1 = tf.layers.Conv2D(x, name="conv1", filters=12, kernel_size=[3, 3], strides=(2, 2),
                                     activation=tf.nn.relu, kernel_initializer=tf.contrib.layers.xavier_initializer(),
                                     bias_initializer=tf.contrib.layers.xavier_initializer())
TypeError: __init__() got multiple values for argument 'filters'

2.分析

Conv2D详情:

class Conv2D(keras_layers.Conv2D, base.Layer):
  def __init__(self, filters,
               kernel_size,
               strides=(1, 1),
               padding='valid',
               data_format='channels_last',
               dilation_rate=(1, 1),
               activation=None,
               use_bias=True,
               kernel_initializer=None,
               bias_initializer=init_ops.zeros_initializer(),
               kernel_regularizer=None,
               bias_regularizer=None,
               activity_regularizer=None,
               kernel_constraint=None,
               bias_constraint=None,
               trainable=True,
               name=None,
               **kwargs):

conv2d详情:

def conv2d(inputs,
           filters,
           kernel_size,
           strides=(1, 1),
           padding='valid',
           data_format='channels_last',
           dilation_rate=(1, 1),
           activation=None,
           use_bias=True,
           kernel_initializer=None,
           bias_initializer=init_ops.zeros_initializer(),
           kernel_regularizer=None,
           bias_regularizer=None,
           activity_regularizer=None,
           kernel_constraint=None,
           bias_constraint=None,
           trainable=True,
           name=None,
           reuse=None):

Conv2D是一个类,第一个参数(除了self)是filters,conv2d是一个函数,第一个参数是inputs,第二个参数是filters,我是用的是tf.layers.Conv2D(x, name=“conv1”, filters=12,**),相当于给了filters两个参数

3.解决方法

把tf.layers.Conv2D()换成tf.layers.conv2d()就可以了

你可能感兴趣的:(错误总结,tensorflow,深度学习)