MCPcopy Index your code
hub / github.com/tflearn/tflearn / batch_normalization

Function batch_normalization

tflearn/layers/normalization.py:20–117  ·  view source on GitHub ↗

Batch Normalization. Normalize activations of the previous layer at each batch. Arguments: incoming: `Tensor`. Incoming Tensor. beta: `float`. Default: 0.0. gamma: `float`. Default: 1.0. epsilon: `float`. Defalut: 1e-5. decay: `float`. Default: 0.9.

(incoming, beta=0.0, gamma=1.0, epsilon=1e-5,
                        decay=0.9, stddev=0.002, trainable=True,
                        restore=True, reuse=False, scope=None,
                        name="BatchNormalization")

Source from the content-addressed store, hash-verified

18
19
20def batch_normalization(incoming, beta=0.0, gamma=1.0, epsilon=1e-5,
21 decay=0.9, stddev=0.002, trainable=True,
22 restore=True, reuse=False, scope=None,
23 name="BatchNormalization"):
24 """ Batch Normalization.
25
26 Normalize activations of the previous layer at each batch.
27
28 Arguments:
29 incoming: `Tensor`. Incoming Tensor.
30 beta: `float`. Default: 0.0.
31 gamma: `float`. Default: 1.0.
32 epsilon: `float`. Defalut: 1e-5.
33 decay: `float`. Default: 0.9.
34 stddev: `float`. Standard deviation for weights initialization.
35 trainable: `bool`. If True, weights will be trainable.
36 restore: `bool`. If True, this layer weights will be restored when
37 loading a model.
38 reuse: `bool`. If True and 'scope' is provided, this layer variables
39 will be reused (shared).
40 scope: `str`. Define this layer scope (optional). A scope can be
41 used to share variables between layers. Note that scope will
42 override name.
43 name: `str`. A name for this layer (optional).
44
45 References:
46 Batch Normalization: Accelerating Deep Network Training by Reducing
47 Internal Covariate Shif. Sergey Ioffe, Christian Szegedy. 2015.
48
49 Links:
50 [http://arxiv.org/pdf/1502.03167v3.pdf](http://arxiv.org/pdf/1502.03167v3.pdf)
51
52 """
53
54 input_shape = utils.get_incoming_shape(incoming)
55 input_ndim = len(input_shape)
56
57 gamma_init = tf.random_normal_initializer(mean=gamma, stddev=stddev)
58
59 with tf.variable_scope(scope, default_name=name, values=[incoming],
60 reuse=reuse) as scope:
61 name = scope.name
62 beta = vs.variable('beta', shape=[input_shape[-1]],
63 initializer=tf.constant_initializer(beta),
64 trainable=trainable, restore=restore)
65 gamma = vs.variable('gamma', shape=[input_shape[-1]],
66 initializer=gamma_init, trainable=trainable,
67 restore=restore)
68 # Track per layer variables
69 tf.add_to_collection(tf.GraphKeys.LAYER_VARIABLES + '/' + name, beta)
70 tf.add_to_collection(tf.GraphKeys.LAYER_VARIABLES + '/' + name, gamma)
71 if not restore:
72 tf.add_to_collection(tf.GraphKeys.EXCL_RESTORE_VARS, beta)
73 tf.add_to_collection(tf.GraphKeys.EXCL_RESTORE_VARS, gamma)
74
75 axis = list(range(input_ndim - 1))
76
77 moving_mean = vs.variable('moving_mean', input_shape[-1:],

Callers 7

block35Function · 0.90
block17Function · 0.90
block8Function · 0.90
__call__Method · 0.85
resnext_blockFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected