1 from __future__
import absolute_import
2 from __future__
import division
3 from __future__
import print_function
4 from __future__
import unicode_literals
17 name=
'batch_normalization',
24 super(BatchNormalization, self).__init__(
25 model, name, input_record, **kwargs)
27 assert isinstance(input_record,
schema.Scalar),
"Incorrect input type" 37 raise ValueError(
"Please specify a correct order")
40 "This layer supports only 4D or 2D tesnors")
53 initializer=(
'ConstantFill', {
'value': 1.0}),
54 optimizer=scale_optim)
57 initializer=(
'ConstantFill', {
'value': 0.0}),
61 initializer=(
'ConstantFill', {
'value': 0.0}),
62 optimizer=model.NoOptim)
65 initializer=(
'ConstantFill', {
'value': 1.0}),
66 optimizer=model.NoOptim)
68 def _add_ops(self, net, is_test, out_blob=None):
69 original_input_blob = self.input_record.field_blobs()
70 input_blob = net.NextScopedBlob(
'expand_input')
72 input_blob = net.ExpandDims(original_input_blob,
75 input_blob = original_input_blob[0]
78 bn_output = self.output_schema.field_blobs()
82 output_blobs = bn_output
84 output_blobs = bn_output + [self.
rm, self.
riv,
85 net.NextScopedBlob(
'bn_saved_mean'),
86 net.NextScopedBlob(
'bn_saved_iv')]
88 net.SpatialBN([input_blob, self.
scale,
96 net.Squeeze(bn_output,
100 def add_train_ops(self, net):
103 def add_eval_ops(self, net):
106 def add_ops(self, net):
def get_next_blob_reference(self, name)
def add_eval_ops(self, net)
def create_param(self, param_name, shape, initializer, optimizer, ps_param=None, regularizer=None)
def _add_ops(self, net, is_test, out_blob=None)