Created
June 23, 2019 18:05
-
-
Save gaphex/2e6a28275a9e999e69bdf84b3f0c4686 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Q = tf.placeholder("float", [dim]) | |
| S = tf.placeholder("float", [None, dim]) | |
| S_norm = tf.placeholder("float", [None, 1]) | |
| Qr = tf.reshape(Q, (1, -1)) | |
| PP = S_norm | |
| QQ = tf.matmul(Qr, tf.transpose(Qr)) | |
| PQ = tf.matmul(S, tf.transpose(Qr)) | |
| distance = PP - 2 * PQ + QQ | |
| distance = tf.sqrt(tf.reshape(distance, (-1,))) | |
| top_neg_dists, top_indices = tf.math.top_k(tf.negative(distance), k=top_k) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment