简体   繁体   English

lasagne.layers.DenseLayer:“__init__() 至少需要 3 个参数”

[英]lasagne.layers.DenseLayer: "__init__() takes at least 3 arguments"

I'm using Lasagne+Theano to create a ResNet and am struggling with the use of DenseLayer.我正在使用 Lasagne+Theano 创建一个 ResNet 并且正在努力使用 DenseLayer。 If i use the example on http://lasagne.readthedocs.io/en/latest/modules/layers/dense.html it works.如果我使用http://lasagne.readthedocs.io/en/latest/modules/layers/dense.html上的示例,它可以工作。

l_in = InputLayer((100, 20))
l1 = DenseLayer(l_in, num_units=50)

But if I want to use it in my project:但是如果我想在我的项目中使用它:

#other layers

resnet['res5c_branch2c'] = ConvLayer(resnet['res5c_branch2b'], num_filters=2048, filter_size=1, pad=0, flip_filters=False)
resnet['pool5'] = PoolLayer(resnet['res5c'], pool_size=7, stride=1, mode='average_exc_pad', ignore_border=False)
resnet['fc1000'] = DenseLayer(resnet['pool5'], num_filter=1000)

Traceback (most recent call last):File "convert_resnet_101_caffe.py", line 167, in <module>
resnet['fc1000'] = DenseLayer(resnet['pool5'], num_filter=1000)TypeError: __init__() takes at least 3 arguments (2 given)

DenseLayer takes two positional arguments: incoming, num_units . DenseLayer接受两个位置参数: incoming, num_units You are instantiating it like this:您正在像这样实例化它:

DenseLayer(resnet['pool5'], num_filter=1000)

Note that this is different than the example code:请注意,这与示例代码不同:

DenseLayer(l_in, num_units=50)

Since you are passing a keyword argument that is not num_units as the second argument, I think num_filter is being interpreted as one of the **kwargs , and DenseLayer is still wanting that num_units` argument, and raising an error since you don't provide it.由于您传递的关键字参数不是num_units作为第二个参数,我认为num_filter被解释为**kwargs ,并且DenseLayer is still wanting that num_units` 参数,并且由于您没有提供而引发错误它。

You can either provide a num_units argument before num_filter , or if that was just a typo, change num_filter to num_units .您可以提供一个num_units之前的说法num_filter ,或者这仅仅是一个错字,改变num_filternum_units (The second option seems more likely to me since, although I am not familiar with the library that you are using, I do not see any reference to num_filter in the documentation you linked, although some classes seem to take a num_filters - note the trailing s - argument.) (第二个选项对我来说似乎更有可能,因为虽然我不熟悉您正在使用的库,但我在您链接的文档中没有看到任何对num_filter引用,尽管有些类似乎采用了num_filters - 请注意尾随s - 参数。)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 类型错误:__init__() 需要至少 3 个参数(给出 2 个) - TypeError: __init__() takes at least 3 arguments (2 given) TypeError:__init __()至少接受3个参数(给定1个) - TypeError: __init__() takes at least 3 arguments (1 given) Django UpdateView“ __init __()至少接受2个参数(给定1个)” - Django UpdateView “__init__() takes at least 2 arguments (1 given)” UpdateView导致错误“ __init __()至少接受2个参数(给定1个)” - UpdateView causing error “__init__() takes at least 2 arguments (1 given)” Django-ModelChoiceField-TypeError-__init __()至少接受2个参数(给定1个) - Django - ModelChoiceField - TypeError - __init__() takes at least 2 arguments (1 given) CNN + RNN错误“ __init __()至少接受4个参数(给定4个)” - Error with CNN + RNN “__init__() takes at least 4 arguments (4 given)” TypeError:__init __()至少接受4个非关键字参数(给定3个) - TypeError: __init__() takes at least 4 non-keyword arguments (3 given) TypeError:__init __()至少接受3个参数(给定5个)Keras - TypeError: __init__() takes at least 3 arguments (5 given) Keras 我得到__init __()在IntegerField上至少需要2个参数(给定1个) - I'm getting __init__() takes at least 2 arguments (1 given) on IntegerField Ansible VM:TypeError:__init __()至少接受3个参数(给定2个) - Ansible VM:TypeError: __init__() takes at least 3 arguments (2 given)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM