Created
August 30, 2019 21:01
-
-
Save Lexie88rus/bf61f83277f939a7eb7a321ef0e9e73f to your computer and use it in GitHub Desktop.
Function to convert model output into a word
This file contains 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
# Define a function which converts output into word | |
def wordFromOutput(output): | |
''' | |
Functions returns an index from the vocabulary and the corresponding word | |
''' | |
top_n, top_i = output.topk(1) | |
category_i = top_i[0].item() | |
return [k for (k, v) in vocab.items() if v == category_i], category_i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment