(model)
return dict(replacements)
Weight-standardize non-output kernels of `model`.
Weight-standardize non-output kernels of `model`.
Weight - standardize non - output kernels of model .
def weight_standardization_replacements(model):
  """Weight-standardize non-output kernels of `model`."""
  if not isinstance(model, ReparameterizableBackbone):
    raise ValueError(
        '`model` must be an instance of `ReparameterizableBackbone`.')
  kernels = filter(lambda v: 'kernel' in v.name and 'output' not in v.name,
                   model.reparameterizables())
  replacements = []
  for v in kernels:
    # Wrap a standardization around the kernel.
    # Kernel has shape HWIO, normalize over HWI
    mean, var = tf.nn.moments(v, axes=[0, 1, 2], keepdims=True)
    # Author code uses std + 1e-5
    replacements.append((v.ref(), (v - mean) / tf.sqrt(var + 1e-10)))
  return dict(replacements)
def weight_standardization_replacements ( model ) : if not isinstance ( model , ReparameterizableBackbone ) : raise ValueError ( '`model` must be an instance of `ReparameterizableBackbone`.' ) kernels = filter ( lambda v : 'kernel' in v . name and 'output' not in v . name , model . reparameterizables ( ) ) replacements = [ ] for v in kernels : # Wrap a standardization around the kernel. # Kernel has shape HWIO, normalize over HWI mean , var = tf . nn . moments ( v , axes = [ 0 , 1 , 2 ] , keepdims = True ) # Author code uses std + 1e-5 replacements . append ( ( v . ref ( ) , ( v - mean ) / tf . sqrt ( var + 1e-10 ) ) ) return dict ( replacements )