Skip to content

Instantly share code, notes, and snippets.

@hanxiao
Created July 13, 2018 02:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hanxiao/7067560cdfb14a70709596a4ff1cfd43 to your computer and use it in GitHub Desktop.
Save hanxiao/7067560cdfb14a70709596a4ff1cfd43 to your computer and use it in GitHub Desktop.
get mean rank of positive labels
def get_pos_mean_rank(self, score, label):
_, d = tf.nn.top_k(score, k=self.size_support)
f = tf.gather(label, d)
g = tf.where(tf.not_equal(f, 0))
return tf.reduce_mean(g)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment