lasagne.layers.DenseLayer: "__init__() takes at least 3 arguments"
<p>I'm using Lasagne+Theano to create a ResNet and am struggling with the use of DenseLayer. If i use the example on <a href="http://lasagne.readthedocs.io/en/latest/modules/layers/dense.html" rel="nofollow">http://lasagne.readthedocs.io/en/latest/modules/layers/dense.html</a> it works.</p>

<pre><code>l_in = InputLayer((100, 20))
l1 = DenseLayer(l_in, num_units=50)
</code></pre>

<p>But if I want to use it in my project:</p>

<pre><code>#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 &lt;module&gt;
resnet['fc1000'] = DenseLayer(resnet['pool5'], num_filter=1000)TypeError: __init__() takes at least 3 arguments (2 given)
</code></pre>

<p><code>DenseLayer</code> takes two positional arguments: <code>incoming, num_units</code>. You are instantiating it like this:</p>

<pre><code>DenseLayer(resnet['pool5'], num_filter=1000)
</code></pre>

<p>Note that this is different than the example code:</p>

<pre><code>DenseLayer(l_in, num_units=50)
</code></pre>

<p>Since you are passing a keyword argument that is <em>not</em> <code>num_units</code> as the second argument, I think <code>num_filter</code> is being interpreted as one of the <code>**kwargs</code>, and <code>DenseLayer is still wanting that</code>num_units` argument, and raising an error since you don't provide it.</p>

<p>You can either provide a <code>num_units</code> argument before <code>num_filter</code>, or if that was just a typo, change <code>num_filter</code> to <code>num_units</code>. (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 <code>num_filter</code> in the documentation you linked, although some classes seem to take a <code>num_filters</code> - note the trailing <code>s</code> - argument.)</p>

python deep-learning theano lasagne