1

I'm using Lasagne+Theano to create a ResNet and am struggling with the use of DenseLayer. If i use the example on http://lasagne.readthedocs.io/en/latest/modules/layers/dense.html it works.

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)
TobSta
  • 766
  • 2
  • 10
  • 29

1 Answers1

1

DenseLayer takes two positional arguments: 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 thatnum_units` argument, and raising an error since you don't provide it.

You can either provide a num_units argument before num_filter, or if that was just a typo, change num_filter to num_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.)

elethan
  • 16,408
  • 8
  • 64
  • 87