Keras:TypeError:(“无法理解关键字参数:”,“nb_depth”)

2024-09-22 14:33:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我在python中使用Keras库制作视频。 我的Keras版本是2.0.2

 kernel_size=3
 model = Sequential()
    model.add(Convolution3D(nb_filters[0], kernel_size,nb_depth=nb_conv[0], nb_row=nb_conv[0], 
    nb_col=nb_conv[0],input_shape=(1, img_rows, img_cols, patch_size), 
    activation='relu'))

我得到以下错误。

 Using Theano Backened
    Traceback (most recent call last):
  File "F:/Project/codes/foreg.py", line 131, in <module>
    input_shape=(1, img_rows, img_cols, patch_size), activation='relu'))
  File "C:\Users\lenov\Anaconda3\envs\3dcnn\lib\site-packages\keras\legacy\interfaces.py", line 88, in wrapper
    return func(*args, **kwargs)
  File "C:\Users\lenov\Anaconda3\envs\3dcnn\lib\site-packages\keras\layers\convolutional.py", line 580, in __init__
    **kwargs)
  File "C:\Users\lenov\Anaconda3\envs\3dcnn\lib\site-packages\keras\layers\convolutional.py", line 100, in __init__
    super(_Conv, self).__init__(**kwargs)
  File "C:\Users\lenov\Anaconda3\envs\3dcnn\lib\site-packages\keras\engine\topology.py", line 277, in __init__
    raise TypeError('Keyword argument not understood:', kwarg)
TypeError: ('Keyword argument not understood:', 'nb_depth')

请帮助我解决这个错误。


Tags: inpyimgsizelibpackageslinesite
3条回答

如错误消息所示:您没有为卷积3d构造函数提供内核大小参数。

签出documentation

来自文档:

Conv3D(filters, kernel_size, strides=(1, 1, 1), padding='valid', data_format=None, dilation_rate=(1, 1, 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)

您需要在过滤器数量之后指定内核大小,例如:

kernel_size = 3
model.add(Convolution3D(nb_filters[0], kernel_size, nb_depth=nb_conv[0], nb_row=nb_conv[0], 
    nb_col=nb_conv[0],input_shape=(1, img_rows, img_cols, patch_size), 
    activation='relu'))

documentation

kernel_size: An integer or tuple/list of 3 integers, specifying the width and height of the 3D convolution window. Can be a single integer to specify the same value for all spatial dimensions.

我通过安装mkdocs解决了我的问题

pip install mkdocs

在工作环境中。

相关问题 更多 >