319d76de1d740a0500b9bc321ddc40bf3c032f71,tensorflow_transform/tf_utils.py,,reduce_batch_count_mean_and_var,#Any#Any#,646
Before Change
if isinstance(x, tf.SparseTensor):
// This means reduce_instance_dims=False.
// TODO(b/112656428): Support SparseTensors with rank other than 2.
if x.get_shape().ndims != 2:
raise NotImplementedError(
"Mean and var only support SparseTensors with rank 2")
col_count, col_indices = x.dense_shape[1], x.indices[:, 1]
x_sum = tf.math.unsorted_segment_sum(x.values, col_indices, col_count)
x_mean = tf.where(tf.math.greater(x_count, 0),
x_sum / x_count,
After Change
x_mean = tf.where(tf.math.greater(x_count, 0),
x_sum / x_count,
tf.zeros_like(x_count, dtype=x.dtype))
x_minus_mean = tf.sparse.add(x, -tf.broadcast_to(x_mean, tf.shape(x)))
x_minus_mean_sparse = tf.SparseTensor(x.indices,
tf.gather_nd(x_minus_mean, x.indices),
x.dense_shape)
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 6
Instances
Project Name: tensorflow/transform
Commit Name: 319d76de1d740a0500b9bc321ddc40bf3c032f71
Time: 2021-01-26
Author: zoy@google.com
File Name: tensorflow_transform/tf_utils.py
Class Name:
Method Name: reduce_batch_count_mean_and_var
Project Name: epfl-lts2/pygsp
Commit Name: 312bd4d73a175079af9bde2cf46a4c187232d14e
Time: 2017-05-18
Author: rodrigo.pena@epfl.ch
File Name: pygsp/operators/operator.py
Class Name:
Method Name: grad
Project Name: epfl-lts2/pygsp
Commit Name: 1a1bff6666ae5d92529da4b2346fa54baebacbce
Time: 2017-06-21
Author: rodrigo.pena@epfl.ch
File Name: pygsp/operators/operator.py
Class Name:
Method Name: grad