mindscience.common.SpectralNorm

class mindscience.common.SpectralNorm(module, n_power_iterations=1, dim=0, eps=1e-12)[source]

Applies spectral normalization to a parameter in the given module.

Spectral normalization stabilizes the training of discriminators (critics) in Generative Adversarial Networks (GANs) by rescaling the weight tensor with spectral norm.

Parameters
  • module (nn.Cell) – Containing module.

  • n_power_iterations (int, optional) – Number of power iterations to calculate spectral norm. Default 1.

  • dim (int, optional) – Dimension corresponding to number of outputs. Default 0.

  • eps (float, optional) – Epsilon for numerical stability in calculating norms. Default 1e-12.

Inputs:
  • input - The positional parameter of containing module.

  • kwargs - The keyword parameter of containing module.

Outputs:

The forward propagation of containing module.