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

Feature-wise Linear Modulation from The difference with AdaIN is that FiLM does not uses the input’s mean and std in its calculations

  • 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


z (2D tensor, optional) – conditioning vector

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

Forward pass

  • x (4D tensor) – input tensor

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


x, conditioned

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