Caffe2 - Python API
A deep learning, cross platform ML framework
normalizer.py
1 # @package optimizer
2 # Module caffe2.python.normalizer
3 from __future__ import absolute_import, division, print_function, unicode_literals
4 
5 
6 class Normalizer(object):
7  def __init__(self):
8  pass
9  """
10  Adds normalization to train_net for given parameter. Its factor ahead of
11  regularization is given when initialization.
12  The param should be a BlobReference.
13  """
14 
15  def __call__(self, net, param):
16  return self._run(net, param)
17 
18  def _run(self, net, param):
19  raise Exception("Not Impelemented")
20 
21 
23  def __init__(self, momentum):
24  super(BatchNormalizer, self).__init__()
25  self._momentum = float(momentum)
26 
27  def _run(self, layer_model, param):
28  return layer_model.BatchNormalization(
29  param, momentum=self._momentum
30  )
31 
32 
34  def __init__(self, epsilon, use_layer_norm_op=True):
35  super(LayerNormalizer, self).__init__()
36  self._epsilon = float(epsilon)
37  self._use_layer_norm_op = use_layer_norm_op
38 
39  def _run(self, layer_model, param):
40  return layer_model.LayerNormalization(
41  param, epsilon=self._epsilon, use_layer_norm_op=self._use_layer_norm_op
42  )
def _run(self, net, param)
Definition: normalizer.py:18