apply_spectral_norm_to_encoder

probly.layers.torch.apply_spectral_norm_to_encoder(module: Module, sn_coeff: float = 3.0) None[source]

Apply spectral normalization in-place to all Conv2d and Linear layers.

For stride-2 1x1 Conv2d (typical ResNet downsampling shortcuts), an AvgPool2d is inserted before a stride-1 copy to remove aliasing, matching the approach of DDU [MKvA+23].

Parameters:
  • module – Encoder module to modify in-place.

  • sn_coeff – Lipschitz coefficient — spectral norm of each weight is clipped to at most this value.