class_docstr: Batch normalization with exponential moving average for test statistics.
  
  See :class:`BaseBatchNorm` for details.
  
  Attributes:
    scale: If ``create_scale=True``, a trainable :tf:`Variable` holding the
      current scale after the module is connected for the first time.
    offset: If ``create_offset``, a trainable :tf:`Variable` holding the current
      offset after the module is connected for the first time.
class_docstr_tok: ["Batch","normalization","with","exponential","moving","average","for","test","statistics",".","See",":","class",":","`","BaseBatchNorm","`","for","details",".","Attributes",":","scale",":","If","``","create_scale=True","``",",","a","trainable",":","tf",":","`","Variable","`","holding","the","current","scale","after","the","module","is","connected","for","the","first","time",".","offset",":","If","``","create_offset","``",",","a","trainable",":","tf",":","`","Variable","`","holding","the","current","offset","after","the","module","is","connected","for","the","first","time","."]
docstr: Constructs a ``BatchNorm`` module.
  
  Args:
    create_scale: whether to create a trainable scale per channel applied
      after the normalization.
    create_offset: whether to create a trainable offset per channel applied
      after normalization and scaling.
    decay_rate: Decay rate of the exponential moving averages of the mean and
      variance.
    eps: Small epsilon to avoid division by zero variance. Defaults to
      ``1e-5``.
    scale_init: Optional initializer for the scale variable. Can only be set
      if ``create_scale=True``. By default scale is initialized to ``1``.
    offset_init: Optional initializer for the offset variable. Can only be set
      if ``create_offset=True``. By default offset is initialized to ``0``.
    data_format: The data format of the input. Can be either
      ``channels_first``, ``channels_last``, ``N...C`` or ``NC...``. By
      default it is ``channels_last``.
    name: Name of the module.
docstr_tok: ["Constructs","a","``","BatchNorm","``","module",".","Args",":","create_scale",":","whether","to","create","a","trainable","scale","per","channel","applied","after","the","normalization",".","create_offset",":","whether","to","create","a","trainable","offset","per","channel","applied","after","normalization","and","scaling",".","decay_rate",":","Decay","rate","of","the","exponential","moving","averages","of","the","mean","and","variance",".","eps",":","Small","epsilon","to","avoid","division","by","zero","variance",".","Defaults","to","``","1e-5","``",".","scale_init",":","Optional","initializer","for","the","scale","variable",".","Can","only","be","set","if","``","create_scale=True","``",".","By","default","scale","is","initialized","to","``","1","``",".","offset_init",":","Optional","initializer","for","the","offset","variable",".","Can","only","be","set","if","``","create_offset=True","``",".","By","default","offset","is","initialized","to","``","0","``",".","data_format",":","The","data","format","of","the","input",".","Can","be","either","``","channels_first","``",",","``","channels_last","``",",","``","N","...","C","``","or","``","NC","...","``",".","By","default","it","is","``","channels_last","``",".","name",":","Name","of","the","module","."]
code: def __init__(
      self,
      create_scale: bool,
      create_offset: bool,
      decay_rate: float = 0.999,
      eps: types.FloatLike = 1e-5,
      scale_init: Optional[initializers.Initializer] = None,
      offset_init: Optional[initializers.Initializer] = None,
      data_format: str = "channels_last",
      name: Optional[str] = None,
  ):
      """Constructs a ``BatchNorm`` module.
  
      Args:
        create_scale: whether to create a trainable scale per channel applied
          after the normalization.
        create_offset: whether to create a trainable offset per channel applied
          after normalization and scaling.
        decay_rate: Decay rate of the exponential moving averages of the mean and
          variance.
        eps: Small epsilon to avoid division by zero variance. Defaults to
          ``1e-5``.
        scale_init: Optional initializer for the scale variable. Can only be set
          if ``create_scale=True``. By default scale is initialized to ``1``.
        offset_init: Optional initializer for the offset variable. Can only be set
          if ``create_offset=True``. By default offset is initialized to ``0``.
        data_format: The data format of the input. Can be either
          ``channels_first``, ``channels_last``, ``N...C`` or ``NC...``. By
          default it is ``channels_last``.
        name: Name of the module.
      """
      with tf.name_scope(name or "batch_norm"):
          moving_mean = moving_averages.ExponentialMovingAverage(
              decay_rate, name="moving_mean"
          )
          moving_variance = moving_averages.ExponentialMovingAverage(
              decay_rate, name="moving_variance"
          )
  
      super().__init__(
          create_scale=create_scale,
          create_offset=create_offset,
          moving_mean=moving_mean,
          moving_variance=moving_variance,
          eps=eps,
          scale_init=scale_init,
          offset_init=offset_init,
          data_format=data_format,
          name=name,
      )
  
file_path: sonnet/sonnet/src/batch_norm.py
imports: from typing import Optional, Tuple
  from sonnet.src import base
  from sonnet.src import initializers
  from sonnet.src import metrics
  from sonnet.src import moving_averages
  from sonnet.src import once
  from sonnet.src import types
  from sonnet.src import utils
  import tensorflow
label_desc: Use image node_id 1 to create a new BatchNorm object from inherited base classes: BaseBatchNorm with example: obj = BatchNorm(create_scale, create_offset, decay_rate, eps, scale_init, offset_init, data_format, name)