MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _fused_batch_norm

Function _fused_batch_norm

tensorflow/contrib/layers/python/layers/layers.py:178–430  ·  view source on GitHub ↗

Adds a Batch Normalization layer from http://arxiv.org/abs/1502.03167. "Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift" Sergey Ioffe, Christian Szegedy Can be used as a normalizer function for conv2d and fully_connected. Note: when tr

(inputs,
                      decay=0.999,
                      center=True,
                      scale=False,
                      epsilon=0.001,
                      activation_fn=None,
                      param_initializers=None,
                      param_regularizers=None,
                      updates_collections=ops.GraphKeys.UPDATE_OPS,
                      is_training=True,
                      reuse=None,
                      variables_collections=None,
                      outputs_collections=None,
                      trainable=True,
                      data_format=DATA_FORMAT_NHWC,
                      zero_debias_moving_mean=False,
                      scope=None)

Source from the content-addressed store, hash-verified

176
177
178def _fused_batch_norm(inputs,
179 decay=0.999,
180 center=True,
181 scale=False,
182 epsilon=0.001,
183 activation_fn=None,
184 param_initializers=None,
185 param_regularizers=None,
186 updates_collections=ops.GraphKeys.UPDATE_OPS,
187 is_training=True,
188 reuse=None,
189 variables_collections=None,
190 outputs_collections=None,
191 trainable=True,
192 data_format=DATA_FORMAT_NHWC,
193 zero_debias_moving_mean=False,
194 scope=None):
195 """Adds a Batch Normalization layer from http://arxiv.org/abs/1502.03167.
196
197 "Batch Normalization: Accelerating Deep Network Training by Reducing
198 Internal Covariate Shift"
199
200 Sergey Ioffe, Christian Szegedy
201
202 Can be used as a normalizer function for conv2d and fully_connected.
203
204 Note: when training, the moving_mean and moving_variance need to be updated.
205 By default the update ops are placed in `tf.GraphKeys.UPDATE_OPS`, so they
206 need to be added as a dependency to the `train_op`. For example:
207
208 ```python
209 update_ops = tf.compat.v1.get_collection(tf.GraphKeys.UPDATE_OPS)
210 with tf.control_dependencies(update_ops):
211 train_op = optimizer.minimize(loss)
212 ```
213
214 One can set updates_collections=None to force the updates in place, but that
215 can have a speed penalty, especially in distributed settings.
216
217 Args:
218 inputs: A tensor with 2 or more dimensions, where the first dimension has
219 `batch_size`. The normalization is over all but the last dimension if
220 `data_format` is `NHWC` and the second dimension if `data_format` is
221 `NCHW`.
222 decay: Decay for the moving average. Reasonable values for `decay` are close
223 to 1.0, typically in the multiple-nines range: 0.999, 0.99, 0.9, etc.
224 Lower `decay` value (recommend trying `decay`=0.9) if model experiences
225 reasonably good training performance but poor validation and/or test
226 performance.
227 center: If True, add offset of `beta` to normalized tensor. If False,
228 `beta` is ignored.
229 scale: If True, multiply by `gamma`. If False, `gamma` is not used. When the
230 next layer is linear (also e.g. `nn.relu`), this can be disabled since the
231 scaling can be done by the next layer.
232 epsilon: Small float added to variance to avoid dividing by zero.
233 activation_fn: Activation function, default set to None to skip it and
234 maintain a linear activation.
235 param_initializers: Optional initializers for beta, gamma, moving mean and

Callers 1

batch_normFunction · 0.85

Calls 10

variable_scopeMethod · 0.80
reshapeMethod · 0.80
is_fully_definedMethod · 0.80
set_partitionerMethod · 0.80
add_to_collectionsMethod · 0.80
get_shapeMethod · 0.45
getMethod · 0.45
constantMethod · 0.45
set_shapeMethod · 0.45
shapeMethod · 0.45

Tested by

no test coverage detected