Skip to content

Instantly share code, notes, and snippets.

@eustin
Last active May 25, 2020 22:21
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 eustin/2a33efa5f2b5c398de433e5640246376 to your computer and use it in GitHub Desktop.
Save eustin/2a33efa5f2b5c398de433e5640246376 to your computer and use it in GitHub Desktop.
num_classes = len(index_word)
index_one_hot = {i: tf.one_hot(x, depth=num_classes) \
for i, x in enumerate(index_word.keys())}
for k, v in index_one_hot.items():
word = index_word[k]
one_hot_vector = v.numpy()
print(f"{word:<6}: {one_hot_vector}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment