Skip to content

Instantly share code, notes, and snippets.

@wezleysherman
Created July 31, 2020 05:11
Show Gist options
  • Save wezleysherman/7766380155ed135307c8ca9af47363f7 to your computer and use it in GitHub Desktop.
Save wezleysherman/7766380155ed135307c8ca9af47363f7 to your computer and use it in GitHub Desktop.
def generate_bar(seed_phrase, model, length_of_bar):
for i in range(length_of_bar):
seed_tokens = pad_sequences(tokenizer.texts_to_sequences([seed_phrase]), maxlen=29)
output_p = model.predict(seed_tokens)
output_word = np.argmax(output_p, axis=1)[0]-1
seed_phrase += " " + str(list(tokenizer.word_index.items())[output_word][0])
return seed_phrase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment