Shortcuts

Data Manipulation

Domain Generalization with MixStyle (MixStyle)

class dglib.generalization.mixstyle.models.mixstyle.MixStyle(p=0.5, alpha=0.1, eps=1e-06)[source]

MixStyle module from DOMAIN GENERALIZATION WITH MIXSTYLE (ICLR 2021). Given input \(x\), we first compute mean \(\mu(x)\) and standard deviation \(\sigma(x)\) across spatial dimension. Then we permute \(x\) and get \(\tilde{x}\), corresponding mean \(\mu(\tilde{x})\) and standard deviation \(\sigma(\tilde{x})\). MixUp is performed using mean and standard deviation

\[\gamma_{mix} = \lambda\sigma(x) + (1-\lambda)\sigma(\tilde{x})\]
\[\beta_{mix} = \lambda\mu(x) + (1-\lambda)\mu(\tilde{x})\]

where \(\lambda\) is instance-wise weight sampled from Beta distribution. MixStyle is then

\[MixStyle(x) = \gamma_{mix}\frac{x-\mu(x)}{\sigma(x)} + \beta_{mix}\]
Parameters
  • p (float) – probability of using MixStyle.

  • alpha (float) – parameter of the Beta distribution.

  • eps (float) – scaling parameter to avoid numerical issues.

Note

MixStyle is only activated during training stage, with some probability \(p\).

@author: Baixu Chen @contact: cbx_99_hasta@outlook.com

dglib.generalization.mixstyle.models.resnet.resnet18(pretrained=False, progress=True, **kwargs)[source]

Constructs a ResNet-18 model with MixStyle.

Parameters
  • pretrained (bool) – If True, returns a model pre-trained on ImageNet

  • progress (bool) – If True, displays a progress bar of the download to stderr

dglib.generalization.mixstyle.models.resnet.resnet34(pretrained=False, progress=True, **kwargs)[source]

Constructs a ResNet-34 model with MixStyle.

Parameters
  • pretrained (bool) – If True, returns a model pre-trained on ImageNet

  • progress (bool) – If True, displays a progress bar of the download to stderr

dglib.generalization.mixstyle.models.resnet.resnet50(pretrained=False, progress=True, **kwargs)[source]

Constructs a ResNet-50 model with MixStyle.

Parameters
  • pretrained (bool) – If True, returns a model pre-trained on ImageNet

  • progress (bool) – If True, displays a progress bar of the download to stderr

dglib.generalization.mixstyle.models.resnet.resnet101(pretrained=False, progress=True, **kwargs)[source]

Constructs a ResNet-101 model with MixStyle.

Parameters
  • pretrained (bool) – If True, returns a model pre-trained on ImageNet

  • progress (bool) – If True, displays a progress bar of the download to stderr

Docs

Access comprehensive documentation for Transfer Learning Library

View Docs

Tutorials

Get started for Transfer Learning Library

Get Started