Created
August 7, 2019 05:37
-
-
Save mohdsanadzakirizvi/503586374468024bcbcb3e1a4408927a to your computer and use it in GitHub Desktop.
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
# generate a sequence of characters with a language model | |
def generate_seq(model, mapping, seq_length, seed_text, n_chars): | |
in_text = seed_text | |
# generate a fixed number of characters | |
for _ in range(n_chars): | |
# encode the characters as integers | |
encoded = [mapping[char] for char in in_text] | |
# truncate sequences to a fixed length | |
encoded = pad_sequences([encoded], maxlen=seq_length, truncating='pre') | |
# predict character | |
yhat = model.predict_classes(encoded, verbose=0) | |
# reverse map integer to character | |
out_char = '' | |
for char, index in mapping.items(): | |
if index == yhat: | |
out_char = char | |
break | |
# append to input | |
in_text += char | |
return in_text |
can u give some examples for the above model. In the analytics vidya is was mentioned example will be given but the space is blank.
A sample input for the above function will be very helpful.
can u give some examples for the above model. In the analytics vidya is was mentioned example will be given but the space is blank.
A sample input for the above function will be very helpful.
same here!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how to execute it