TensorFlow 2.0 Beta is available Learn more

tf.contrib.gan.features.spectral_norm_regularizer

View source on GitHub

Returns a functions that can be used to apply spectral norm regularization.

tf.contrib.gan.features.spectral_norm_regularizer(
    scale,
    power_iteration_rounds=1,
    scope=None
)

Small spectral norms enforce a small Lipschitz constant, which is necessary for Wasserstein GANs.

Args:

  • scale: A scalar multiplier. 0.0 disables the regularizer.
  • power_iteration_rounds: The number of iterations of the power method to perform. A higher number yields a better approximation.
  • scope: An optional scope name.

Returns:

A function with the signature sn(weights) that applies spectral norm regularization.

Raises:

  • ValueError: If scale is negative or if scale is not a float.