[英]__init__() got multiple values for argument 'padding'
def get_model(summary=False, backend='tf'):
""" Return the Keras model of the network
"""
model = Sequential()
if backend == 'tf':
input_shape=(256, 80, 60, 1) # l, h, w, c
else:
input_shape=(1, 256, 80, 60) # c, l, h, w
model.add(Convolution3D(64, 3, 3, 3, activation='relu',
padding='same', name='conv1',
input_shape=input_shape))
model.add(MaxPooling3D(pool_size=(1, 2, 2), strides=(1, 2, 2),
padding='valid', name='pool1'))
# 2nd layer group
model.add(Convolution3D(128, 3, 3, 3, activation='relu',
padding='same', name='conv2'))
model.add(MaxPooling3D(pool_size=(2, 2, 2), strides=(2, 2, 2),
padding='valid', name='pool2'))
+ other layers as well
if __name__ == '__main__':
model = get_model(summary=True,backend='tf')
I am trying to implement the c3d model for video classification.我正在尝试实现 c3d model 进行视频分类。
Input size = 256 X 80 X 60 X 1输入尺寸 = 256 X 80 X 60 X 1
The error is showing in the main function.该错误显示在主 function 中。
I am trying to use the C3D model for video classification.我正在尝试使用 C3D model 进行视频分类。 256 frames, 80 H, 60 W, 1 channel(grayscale) But encountering this prob of padding (earlier was using tf = 1.14.0, it worked fine now tf = 2.2.0)
256 帧,80 H,60 W,1 通道(灰度)但遇到这种填充问题(之前使用 tf = 1.14.0,现在 tf = 2.2.0 工作正常)
This is the function signature:这是 function 签名:
tf.keras.layers.Conv3D(
filters, kernel_size, strides=(1, 1, 1), padding='valid',
data_format=None, dilation_rate=(1, 1, 1), groups=1, activation=None,
use_bias=True, kernel_initializer='glorot_uniform',
bias_initializer='zeros', kernel_regularizer=None,
bias_regularizer=None, activity_regularizer=None, kernel_constraint=None,
bias_constraint=None, **kwargs
)
It requires 2 positional arguments .它需要2 个位置 arguments 。
the first is a filter which is integer (64)第一个是过滤器,它是integer (64)
the second is kernel_size
which is integer or tuple of 3 integers .第二个是
kernel_size
,它是integer或3 个整数的元组。
Because your input is not a (3, 3, 3)
tuple it takes kernel_size=3
and then assigns the rest of 3, 3
to the keyed arguments which are strides
and padding
, but then it sees another padding=
assignment so it errors.因为您的输入不是
(3, 3, 3)
元组,所以它需要kernel_size=3
然后将3, 3
的 rest 分配给键控 arguments ,它们是strides
和padding
,但随后它看到另一个padding=
分配,因此它出错。
bottom line, call:底线,请致电:
model.add(Convolution3D(64, (3, 3, 3), activation='relu',
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.