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

Function _fused_normalize_batch_in_training

tensorflow/python/keras/backend.py:2434–2467  ·  view source on GitHub ↗

Fused version of `normalize_batch_in_training`. Arguments: x: Input tensor or variable. gamma: Tensor by which to scale the input. beta: Tensor with which to center the input. reduction_axes: iterable of integers, axes over which to normalize. epsilon: Fuzz

(x,
                                       gamma,
                                       beta,
                                       reduction_axes,
                                       epsilon=1e-3)

Source from the content-addressed store, hash-verified

2432
2433
2434def _fused_normalize_batch_in_training(x,
2435 gamma,
2436 beta,
2437 reduction_axes,
2438 epsilon=1e-3):
2439 """Fused version of `normalize_batch_in_training`.
2440
2441 Arguments:
2442 x: Input tensor or variable.
2443 gamma: Tensor by which to scale the input.
2444 beta: Tensor with which to center the input.
2445 reduction_axes: iterable of integers,
2446 axes over which to normalize.
2447 epsilon: Fuzz factor.
2448
2449 Returns:
2450 A tuple length of 3, `(normalized_tensor, mean, variance)`.
2451 """
2452 if list(reduction_axes) == [0, 1, 2]:
2453 normalization_axis = 3
2454 tf_data_format = 'NHWC'
2455 else:
2456 normalization_axis = 1
2457 tf_data_format = 'NCHW'
2458
2459 if gamma is None:
2460 gamma = constant_op.constant(
2461 1.0, dtype=x.dtype, shape=[x.shape[normalization_axis]])
2462 if beta is None:
2463 beta = constant_op.constant(
2464 0.0, dtype=x.dtype, shape=[x.shape[normalization_axis]])
2465
2466 return nn.fused_batch_norm(
2467 x, gamma, beta, epsilon=epsilon, data_format=tf_data_format)
2468
2469
2470@keras_export('keras.backend.normalize_batch_in_training')

Callers 1

Calls 1

constantMethod · 0.45

Tested by

no test coverage detected