Skip to content

Commit 66a81f9

Browse files
authored
Optimization in SpearmansRank computation (#2743)
1 parent d4a915d commit 66a81f9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tensorflow_addons/metrics/streaming_correlations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,9 @@ def result(self):
278278
n = tf.cast(self.n, tf.float32)
279279

280280
nrow_ = tf.where(nrow > 0, nrow, -1.0)
281-
rrow = tf.pad(tf.cumsum(nrow)[:-1], [[1, 0]]) + (nrow_ - n) / 2
281+
rrow = tf.cumsum(nrow, exclusive=True) + (nrow_ - n) / 2
282282
ncol_ = tf.where(ncol > 0, ncol, -1.0)
283-
rcol = tf.pad(tf.cumsum(ncol)[:-1], [[1, 0]]) + (ncol_ - n) / 2
283+
rcol = tf.cumsum(ncol, exclusive=True) + (ncol_ - n) / 2
284284

285285
rrow = rrow / tf.math.sqrt(tf.reduce_sum(nrow * tf.square(rrow)))
286286
rcol = rcol / tf.math.sqrt(tf.reduce_sum(ncol * tf.square(rcol)))

0 commit comments

Comments
 (0)