TrainingExtensions/tensorflow/src/python/aimet_tensorflow/keras/batch_norm_fold.py
def _get_bn_params(bn: tf.keras.layers.BatchNormalization) -> libpymo.BNParams():
    """
    helper to populate BN params from given BN Layer, required for fold

    :param bn: BatchNorm Layer
    :return: return bn params in libpymo.TensorParams() format.
    """

    bn_params = libpymo.BNParams()

    bn_params.gamma = bn.gamma.numpy().reshape(-1)
    bn_params.beta = bn.beta.numpy().reshape(-1)
    bn_params.runningMean = bn.moving_mean.numpy().reshape(-1)
    bn_params.runningVar = bn.moving_variance.numpy().reshape(-1)
    epsilon = bn.epsilon
    var = bn.moving_variance.numpy()
    var_with_epsilon = var + epsilon
    sigma = np.sqrt(var_with_epsilon)
    bn_params.runningVar = sigma

    return bn_params

    helper to populate BN params from given BN Layer, required for fold

    :param bn: BatchNorm Layer
    :return: return bn params in libpymo.TensorParams() format.
    
helper to populate BN params from given BN Layer, required for fold
helper to populate BN params from given BN Layer required for fold
def _get_bn_params(bn: tf.keras.layers.BatchNormalization) -> libpymo.BNParams():
    bn_params = libpymo.BNParams()
    bn_params.gamma = bn.gamma.numpy().reshape(-1)
    bn_params.beta = bn.beta.numpy().reshape(-1)
    bn_params.runningMean = bn.moving_mean.numpy().reshape(-1)
    bn_params.runningVar = bn.moving_variance.numpy().reshape(-1)
    epsilon = bn.epsilon
    var = bn.moving_variance.numpy()
    var_with_epsilon = var + epsilon
    sigma = np.sqrt(var_with_epsilon)
    bn_params.runningVar = sigma
    return bn_params
def _get_bn_params ( bn : tf . keras . layers . BatchNormalization ) -> libpymo . BNParams ( ) : bn_params = libpymo . BNParams ( ) bn_params . gamma = bn . gamma . numpy ( ) . reshape ( - 1 ) bn_params . beta = bn . beta . numpy ( ) . reshape ( - 1 ) bn_params . runningMean = bn . moving_mean . numpy ( ) . reshape ( - 1 ) bn_params . runningVar = bn . moving_variance . numpy ( ) . reshape ( - 1 ) epsilon = bn . epsilon var = bn . moving_variance . numpy ( ) var_with_epsilon = var + epsilon sigma = np . sqrt ( var_with_epsilon ) bn_params . runningVar = sigma return bn_params
helper to populate BN params from given BN Layer, required for fold
helper to populate BN params from given BN Layer required for fold
"""
    helper to populate BN params from given BN Layer, required for fold

    :param bn: BatchNorm Layer
    :return: return bn params in libpymo.TensorParams() format.
    """
return bn params in libpymo.TensorParams() format.
return bn params in libpymo . TensorParams () format .
bn
tf.keras.layers.BatchNormalization
None