kakaobrain / miro

Official PyTorch implementation of MIRO (ECCV 2022)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't implement MixSytle

andrew0411 opened this issue · comments

Thank you for your excellent work. Full of insights and re-using of pre-trained models concept was impressive.

I have tried to reproduce the results of Mixstyle reported on the paper.

But there is an error while using Mixstyle algorithm as below

File "/workspace/domainbed/algorithms/algorithms.py", line 190, in __init__
    self.featurizer = networks.ResNet(input_shape, self.hparams, network)
TypeError: __init__() takes 3 positional arguments but 4 were given

In the code of miro/domainbed class Mixstyle(Algorithm) the featurizer is defined as self.featurizer = networks.ResNet(input_shape, self.hparams, network)

From previous work /swad/domainbed/networks.py there are 4 arguments which was ok with Mixstyle algorithm

class ResNet(torch.nn.Module):
    """ResNet with the softmax chopped off and the batchnorm frozen"""

    def __init__(self, input_shape, hparams, network=None):
        super(ResNet, self).__init__()
        if hparams["resnet18"]:
            if network is None:
                network = torchvision.models.resnet18(pretrained=hparams["pretrained"])
            self.network = network...

but in MIRO/domainbed/networks/networks.py the featurizer cannot be defined.

class ResNet(torch.nn.Module):
    """ResNet with the softmax chopped off and the batchnorm frozen"""

    def __init__(self, input_shape, hparams):
        super(ResNet, self).__init__()
        self.network, self.n_outputs = get_backbone(
            hparams.model,
            preserve_readout=False,
            pretrained=hparams.pretrained
        )...

Hello, thanks for reporting this issue!

A simple solution is just to use SWAD code. The experiments about MixStyle are not the purpose of this repository (the numbers in the paper are also adopted from SWAD paper). We'll see if we can fix the problem later, but it is also considered to remove MixStyle from this repository.

Thank you !