Skip to main content

Nearest neighbours word embedding computation.

Project description

TensorFlow Nearest Neighbours Op

Given an embedding matrix EM, and batch of word embeddings x find nearest embedding for each token x_ij in EM.

import tensorflow as tf
from tensorflow_nearest_neighbours import nearest_neighbours
tf.debugging.set_log_device_placement(True)

x = tf.random.uniform(shape=[8, 10, 32])
EM = tf.random.uniform(shape=[500, 32])
result = nearest_neighbours(x, EM)
print(result.shape)

Instalation

pip install tensorflow_nearest_neighbours

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

tensorflow_nearest_neighbours-0.0.1.dev1-cp310-cp310-macosx_13_0_arm64.whl (140.1 kB view hashes)

Uploaded CPython 3.10 macOS 13.0+ ARM64

tensorflow_nearest_neighbours-0.0.1.dev1-cp39-cp39-macosx_13_0_arm64.whl (140.1 kB view hashes)

Uploaded CPython 3.9 macOS 13.0+ ARM64

tensorflow_nearest_neighbours-0.0.1.dev1-cp38-cp38-macosx_13_0_arm64.whl (140.1 kB view hashes)

Uploaded CPython 3.8 macOS 13.0+ ARM64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page