Skip to content

Instantly share code, notes, and snippets.

@AmrutaKoshe
Created June 24, 2021 13:34
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 AmrutaKoshe/5b18bae063fded882beb9167011f9fc0 to your computer and use it in GitHub Desktop.
Save AmrutaKoshe/5b18bae063fded882beb9167011f9fc0 to your computer and use it in GitHub Desktop.
Tokenizing labels
# Tokenize label data
label_tokenizer = Tokenizer(lower=True)
label_tokenizer.fit_on_texts(labels)
label_index = label_tokenizer.word_index
print(dict(list(label_index.items())))
# Print example label encodings from train and test datasets
train_label_sequences = label_tokenizer.texts_to_sequences(train_labels)
test_label_sequences = label_tokenizer.texts_to_sequences(test_labels)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment