TypeError: __init__() missing 1 required positional argument: 'num_features'

Here is the error details:

Traceback (most recent call last):
File “test_toy_v2_model.py”, line 25, in
model = get_unet_model(norm_layer=torch.nn.BatchNorm2d, with_proposals=True)
File “…/adaptis/model/toy/models.py”, line 13, in get_unet_model
norm_layer=norm_layer),
File “…/adaptis/model/toy/unet.py”, line 12, in init
self.image_bn = norm_layer()
TypeError: init() missing 1 required positional argument: ‘num_features’

Related Codes:
1)
with self.name_scope():
self.image_bn = norm_layer(in_channels = 3)
prev_ch = 0

def get_unet_model(norm_layer, channel_width=32, max_width=512, with_proposals=False, rescale_output=(0.2, -1.7)):
return AdaptIS(
feature_extractor=UNet(num_blocks=4, first_channels=channel_width, max_width=max_width,
norm_layer=norm_layer),
adaptis_head=ToyAdaptISHead(
SimpleConvController(3, channel_width, norm_layer=norm_layer),
ch=channel_width, norm_radius=42, with_coord_features=True,
norm_layer=norm_layer,
rescale_output=rescale_output
),
segmentation_head=ConvHead(2, channels=32, num_layers=3, norm_layer=norm_layer),
proposal_head=ConvHead(1, channels=32, num_layers=2, norm_layer=norm_layer),
with_proposals=with_proposals
)

model = get_unet_model(norm_layer=torch.nn.BatchNorm2d, with_proposals=True)

Could anyone please why this error is occurring and how to solve it? Thanks.

The error is raised in:

File “…/adaptis/model/toy/unet.py”, line 12, in __init__
self.image_bn = norm_layer()

where norm_layer most likely expects the num_features argument, while nothing is passed.

PS: you can post code snippets by wrapping them into three backticks ```, which makes debugging easier. :wink: