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}\]
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.
-
dglib.generalization.mixstyle.models.resnet.
resnet34
(pretrained=False, progress=True, **kwargs)[source]¶ Constructs a ResNet-34 model with MixStyle.
-
dglib.generalization.mixstyle.models.resnet.
resnet50
(pretrained=False, progress=True, **kwargs)[source]¶ Constructs a ResNet-50 model with MixStyle.