docstr: Calculate values of initialized vars from Salimans and Kingma (2016).
docstr_tok: ["Calculate","values","of","initialized","vars","from","Salimans","and","Kingma","(","2016",")","."]
code: def _calculate_true_initial_variables_conv(
      self, inputs, num_filters, transpose=False
  ):
      """Calculate values of initialized vars from Salimans and Kingma (2016)."""
  
      data_dim = inputs.shape[1:]
      norm_axes_out = (0, 1, 2)
      if transpose:
          conv = tfkl.Conv2DTranspose
          norm_axes_kernel = (0, 1, 3)
      else:
          conv = tfkl.Conv2D
          norm_axes_kernel = norm_axes_out
  
      # Initialize a convolutional layer and normalize the kernel
      conv_layer = conv(
          filters=num_filters,
          kernel_size=(2, 2),
          kernel_initializer="ones",
      )
      conv_layer.build(input_shape=(None,) + data_dim)
  
      self.evaluate([v.initializer for v in conv_layer.weights])
      conv_layer.kernel = tf.nn.l2_normalize(
          conv_layer.kernel, axis=norm_axes_kernel
      )
  
      # Calculate initial parameter values (Equation 6 of Salimans and Kingma
      # (2016))
      x_init = self.evaluate(conv_layer(inputs))
      m_init = np.mean(x_init, axis=norm_axes_out)
      v_init = np.var(x_init, axis=norm_axes_out)
      scale_init = 1.0 / np.sqrt(v_init + 1e-10)
      true_init_g = scale_init
      true_init_bias = -m_init * scale_init
      return true_init_g, true_init_bias
  
imports: import tempfile
  from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.internal import tf_keras
  from tensorflow_probability.python.layers import weight_norm
label_desc: Use image node_id 5 for calling the WeightNormTest obj's underlying member method code with example usage: obj._calculate_true_initial_variables_conv(inputs, num_filters, transpose) and returns: true_init_g,  true_init_bias