Skip to content

Commit 26c133e

Browse files
committed
- Removed unnecessary padding op
1 parent 50690b0 commit 26c133e

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

tensorflow_addons/metrics/kendalls_tau.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,9 @@ def update_state(self, y_true, y_pred, sample_weight=None):
151151

152152
def result(self):
153153
m = tf.cast(self.m, tf.float32)
154-
n_cap = tf.cumsum(
155-
tf.cumsum(
156-
tf.slice(tf.pad(m, [[1, 0], [1, 0]]), [0, 0], self.m.shape),
157-
axis=0,
158-
),
159-
axis=1,
160-
)
154+
n_cap = tf.cumsum(tf.cumsum(m, axis=0), axis=1)
161155
# Number of concordant pairs.
162-
p = tf.math.reduce_sum(tf.multiply(n_cap, m))
156+
p = tf.math.reduce_sum(tf.multiply(n_cap[:-1, :-1], m[1:, 1:]))
163157
sum_m_squard = tf.math.reduce_sum(tf.math.square(m))
164158
# Ties in x.
165159
t = (

0 commit comments

Comments
 (0)