docstr: Convert a Batch Normalization layer.
docstr_tok: ["Convert","a","Batch","Normalization","layer","."]
code: def emit_BatchNorm(self, IR_node):
      """
      Convert a Batch Normalization layer.
      """
      # Get input and output names
      input_name = self.IR_graph.get_parent(IR_node.name, [0]).real_name
  
      axis = IR_node.get_attr("axis", -1)
      nb_channels = IR_node.get_attr("_output_shapes")[0].dim[axis].size
  
      # Set parameters
      # Parameter arrangement in Keras: gamma, beta, mean, variance
      weights = self.weights_dict[IR_node.name]
      mean = weights["mean"]
      std = weights["var"]
      gamma = weights.get("scale", np.ones(mean.shape))
      beta = weights.get("bias", np.zeros(mean.shape))
  
      # compute adjusted parameters
      # Reference: parameter transformation https://github.com/apple/coremltools/issues/153
      variance = std * std
      f = 1.0 / np.sqrt(std + IR_node.get_attr("epsilon"))
      gamma1 = gamma * f
      beta1 = beta - gamma * mean * f
      mean[:] = 0.0  # mean
      variance[:] = 1.0 - 0.00001  # stddev
  
      self.builder.add_batchnorm(
          name=IR_node.real_name,
          channels=nb_channels,
          gamma=gamma1,
          beta=beta1,
          mean=mean,
          variance=variance,
          input_name=input_name,
          output_name=IR_node.real_name,
      )
  
imports: from __future__ import division
  import os
  import numpy
  from six import string_types
  from mmdnn.conversion.common.IR.IR_graph import IRGraph, IRGraphNode
  import mmdnn.conversion.common.IR.graph_pb2
  from mmdnn.conversion.common.IR.graph_pb2 import NodeDef, GraphDef, DataType
  from mmdnn.conversion.common.DataStructure.emitter import Emitter
  from mmdnn.conversion.common.utils import *
  from mmdnn.conversion.coreml.coreml_utils import _infer_coreml_input_shape
  from coremltools.models.neural_network import NeuralNetworkBuilder
  from coremltools.models import datatypes
  from coremltools.models import MLModel
  from coremltools.models.utils import save_spec
label_desc: Use image node_id 41 for calling the CoreMLEmitter obj's underlying member method code with example usage: obj.emit_BatchNorm(IR_node) without return types