Runtime & Typing
tensorflow/tensorflow · Python, C API
Fixed dynamic TypeError in tf.nn.weighted_moments when axes are Tensor instances, ensured PosixPath compatibility in runtime imports, and standardized specific exception typing across tensorflow/python and tensorflow/tools.
Verify with Bazel
Run the upstream regression suite in tensorflow/tensorflow for this subsystem.
$bazel test //tensorflow/python/ops:nn_batchnorm_testChanged Files (1)
1. Introduction & Motivation
In TensorFlow's neural network normalization ops, tf.nn.weighted_moments reduces across user-specified axes. When keep_dims=False, the implementation calls array_ops.squeeze(x, axis=axes). In eager mode, squeeze_eager_fallback strictly requires axis to be a Python list or tuple, causing a dynamic TypeError whenever axes was passed as a tf.Tensor.
2. Mathematical & Shape Flow
weighted_moments computes the weighted mean and variance over axes:
3. Verification & References
Added testTensorAxesKeepdimsFalse in nn_batchnorm_test.py (regression test for GitHub issue #101580).
- Ioffe & Szegedy, Batch Normalization: Accelerating Deep Network Training, ICML 2015.