AdaIN2d

class torchelie.nn.AdaIN2d(channels: int, cond_channels: int)

Adaptive InstanceNormalization from *Arbitrary Style Transfer in Real-time with Adaptive Instance Normalization* (Huang et al, 2017)

Parameters
  • channels (int) – number of input channels

  • cond_channels (int) – number of conditioning channels from which bias and scale will be derived

condition(z: torch.Tensor)None

Conditions the layer before the forward pass if z will not be present when calling forward

Parameters

z (2D tensor, optional) – conditioning vector

forward(x: torch.Tensor, z: Optional[torch.Tensor] = None)torch.Tensor

Forward pass

Parameters
  • x (4D tensor) – input tensor

  • z (2D tensor, optional) – conditioning vector. If not present, condition(z) must be called first

Returns

x, renormalized

bias: Optional[torch.Tensor]
weight: Optional[torch.Tensor]