Performs a batch normalization using a standard set of parameters.
422371
def batch_norm(inputs, training, data_format):
  """"""
  # We set fused=True for a significant performance boost. See
  # https://www.tensorflow.org/performance/performance_guide#common_fused_ops
  outputs = tf.layers.batch_normalization(
      inputs=inputs, axis=1 if data_format == 'channels_first' else 3,
      momentum=_BATCH_NORM_DECAY, epsilon=_BATCH_NORM_EPSILON, center=True,
      scale=True, training=training, fused=True)

  resnet_log_helper.log_batch_norm(
      input_tensor=inputs, output_tensor=outputs, momentum=_BATCH_NORM_DECAY,
      epsilon=_BATCH_NORM_EPSILON, center=True, scale=True, training=training)

  return outputs
1014489
private void normalize() {
		for(int i = 0; i < vocab.size(); ++i) {
			double len = 0;
			for(int j = i * layerSize; j < (i + 1) * layerSize; ++j)
				len += vectors.get(j) * vectors.get(j);
			len = Math.sqrt(len);

			for(int j = i * layerSize; j < (i + 1) * layerSize; ++j)
				vectors.put(j, vectors.get(j) / len);
		}
	}
1048714
def _batch(self,
               vectors,
               batch_size,
               num,
               show_progressbar,
               return_names):
        """"""
        vectors = self.normalize(vectors)

        # Single transpose, makes things faster.
        reference_transposed = self.norm_vectors.T

        for i in tqdm(range(0, len(vectors), batch_size),
                      disable=not show_progressbar):

            distances = vectors[i: i+batch_size].dot(reference_transposed)
            # For safety we clip
            distances = np.clip(distances, a_min=.0, a_max=1.0)
            if num == 1:
                sorted_indices = np.argmax(distances, 1)[:, None]
            else:
                sorted_indices = np.argpartition(-distances, kth=num, axis=1)
                sorted_indices = sorted_indices[:, :num]
            for lidx, indices in enumerate(sorted_indices):
                dists = distances[lidx, indices]
                if return_names:
                    dindex = np.argsort(-dists)
                    yield [(self.indices[indices[d]], dists[d])
                           for d in dindex]
                else:
                    yield list(-1 * np.sort(-dists))
268980
def normalize(numbers, total=1.0):  #from AI: A Modern Appproach
    
    k = total / sum(numbers)
    return [k * n for n in numbers]
263960
def learn_batch(self, inputBatch):
        """"""
        X = inputBatch
        Y = self.encode_batch(X)
        self.update_statistics(Y) 
        self.update_weights(X,Y)
        return Y
728476
def normalize_example(self, example, hparams):
    """"""

    length = self.max_length(hparams)
    def _to_constant_shape(tensor):
      tensor = tensor[:length]
      tensor = tf.pad(tensor, [(0, length - tf.shape(tensor)[0])])
      return tf.reshape(tensor, [length])

    if self.has_inputs:
      example['inputs'] = _to_constant_shape(example['inputs'])
      example['targets'] = _to_constant_shape(example['targets'])
    elif 'inputs' in example:
      if self.packed_length:
        raise ValueError('cannot concatenate packed examples on the fly.')
      inputs = example.pop('inputs')[:-1]  # Remove EOS token.
      targets = tf.concat([inputs, example['targets']], 0)
      example['targets'] = _to_constant_shape(targets)
    else:
      example['targets'] = _to_constant_shape(example['targets'])
    if self.packed_length:
      if self.has_inputs:
        if 'inputs_segmentation' in example:
          example['inputs_segmentation'] = _to_constant_shape(
              example['inputs_segmentation'])
          example['inputs_position'] = _to_constant_shape(
              example['inputs_position'])
        else:
          example['inputs_segmentation'] = tf.to_int64(
              tf.not_equal(example['inputs'], 0))
          example['inputs_position'] = (
              example['inputs_segmentation'] * tf.range(length, dtype=tf.int64))
      if 'targets_segmentation' in example:
        example['targets_segmentation'] = _to_constant_shape(
            example['targets_segmentation'])
        example['targets_position'] = _to_constant_shape(
            example['targets_position'])
      else:
        example['targets_segmentation'] = tf.to_int64(
            tf.not_equal(example['targets'], 0))
        example['targets_position'] = (
            example['targets_segmentation'] * tf.range(length, dtype=tf.int64))
    return example
16629
def init_params(net):
    ''''''
    for m in net.modules():
        if isinstance(m, nn.Conv2d):
            init.kaiming_normal(m.weight, mode='fan_out')
            if m.bias:
                init.constant(m.bias, 0)
        elif isinstance(m, nn.BatchNorm2d):
            init.constant(m.weight, 1)
            init.constant(m.bias, 0)
        elif isinstance(m, nn.Linear):
            init.normal(m.weight, std=1e-3)
            if m.bias:
                init.constant(m.bias, 0)
879891
def lpnormalization(attrs, inputs, proto_obj):
    """"""
    new_attrs = translation_utils._fix_attribute_names(attrs, {'p': 'ord'})
    axis = int(attrs.get("axis", -1))
    new_attrs.update(axis=axis)
    return 'norm', new_attrs, inputs
1188331
def _normalize(x, cmin=None, cmax=None, clip=True):
    """"""
    if not isinstance(x, np.ndarray):
        x = np.array(x)
    if cmin is None:
        cmin = x.min()
    if cmax is None:
        cmax = x.max()
    if cmin == cmax:
        return .5 * np.ones(x.shape)
    else:
        cmin, cmax = float(cmin), float(cmax)
        y = (x - cmin) * 1. / (cmax - cmin)
        if clip:
            y = np.clip(y, 0., 1.)
        return y
802836
private void normalizeL2(double[] scores) {
		double square_sum = 0.0;
		for (int i = 0; i < scores.length; i++) {
			square_sum += (scores[i] * scores[i]);
		}
		double norm = Math.sqrt(square_sum);
		if (norm != 0)
			for (int i = 0; i < scores.length; i++) {
				scores[i] = scores[i] / norm;
			}
	}
468358
def normalize(self):
        
        maximum = self.max()
        if maximum:
            self.values = [value / maximum for value in self.values]
858902
def normalize(data):
    
    out_data = data.copy()

    for i, sample in enumerate(out_data):
        out_data[i] /= sum(out_data[i])

    return out_data
978878
def _build_scale_offset(self, dtype):
    """"""

    # tf.nn.fused_batch_norm accepts float16 batch data, but not scale/offset.
    if self._fused and dtype == tf.float16:
      dtype = tf.float32

    # The fused batch norm operation needs the beta, gamma variables,
    # so in this case we build them and set the trainable option according
    # to the values of _offset and _scale.
    self._beta = None
    if self._offset or self._fused:
      if self.BETA not in self._initializers:
        self._initializers[self.BETA] = create_beta_initializer()
      self._beta = tf.get_variable(
          self.BETA,
          dtype=dtype,
          shape=self._mean_shape,
          initializer=self._initializers[self.BETA],
          partitioner=self._partitioners.get(self.BETA, None),
          regularizer=self._regularizers.get(self.BETA, None),
          trainable=self._offset)

    self._gamma = None
    if self._scale or self._fused:
      if self.GAMMA not in self._initializers:
        self._initializers[self.GAMMA] = create_gamma_initializer()
      self._gamma = tf.get_variable(
          self.GAMMA,
          dtype=dtype,
          shape=self._mean_shape,
          initializer=self._initializers[self.GAMMA],
          partitioner=self._partitioners.get(self.GAMMA, None),
          regularizer=self._regularizers.get(self.GAMMA, None),
          trainable=self._scale)
198258
def calculate_batch_normalization_output_shapes(operator):
    '''
    
    '''
    check_input_and_output_numbers(operator, input_count_range=1, output_count_range=1)
    check_input_and_output_types(operator, good_input_types=[FloatTensorType])

    input_shape = operator.inputs[0].type.shape
    if len(input_shape) not in [2, 4]:
        raise RuntimeError('Input must be a 2-D or a 4-D tensor')

    operator.outputs[0].type.shape = copy.deepcopy(operator.inputs[0].type.shape)
623939
public void normalize() {
        for (T key : keySet()) {
            setCount(key, getCount(key) / totalCount.get());
        }

        rebuildTotals();
    }
670507
public static void normalization(char[] charArray)
    {
        assert charArray != null;
        for (int i = 0; i < charArray.length; i++)
        {
            charArray[i] = CONVERT[charArray[i]];
        }
    }
1336216
def _parse_normalization_kwargs(self, use_batch_norm, batch_norm_config,
                                  normalization_ctor, normalization_kwargs):
    """"""
    if use_batch_norm is not None:
      # Delete this whole block when deprecation is done.
      util.deprecation_warning(
          "`use_batch_norm` kwarg is deprecated. Change your code to instead "
          "specify `normalization_ctor` and `normalization_kwargs`.")
      if not use_batch_norm:
        # Explicitly set to False - normalization_{ctor,kwargs} has precedence.
        self._check_and_assign_normalization_members(normalization_ctor,
                                                     normalization_kwargs or {})
      else:  # Explicitly set to true - new kwargs must not be used.
        if normalization_ctor is not None or normalization_kwargs is not None:
          raise ValueError(
              "if use_batch_norm is specified, normalization_ctor and "
              "normalization_kwargs must not be.")
        self._check_and_assign_normalization_members(batch_norm.BatchNorm,
                                                     batch_norm_config or {})
    else:
      # Old kwargs not set, this block will remain after removing old kwarg.
      self._check_and_assign_normalization_members(normalization_ctor,
                                                   normalization_kwargs or {})