Missed TensorFlow World? Check out the recap. Learn more


A context manager that enables Spectral Normalization for Keras.


Keras doesn't respect the custom_getter in the VariableScope, so this is a bit of a hack to make things work.


with keras_spectral_normalization(): net = discriminator_fn(net)


  • name_filter: Optionally, a method that takes a Variable name as input and returns whether this Variable should be normalized.
  • power_iteration_rounds: The number of iterations of the power method to perform per step. A higher number yields a better approximation of the true spectral norm.


A context manager that wraps the standard Keras variable creation method with the spectral_normalization_custom_getter.