Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Is it possible to generate from seed text? #35

Open
deeptibhegde opened this issue Aug 22, 2018 · 2 comments
Open

Is it possible to generate from seed text? #35

deeptibhegde opened this issue Aug 22, 2018 · 2 comments

Comments

@deeptibhegde
Copy link

I am hoping to use this in an application where the algorithm completes a sentence for you. Where in rnn_play.py is the seed text given?

@martin-gorner
Copy link
Owner

Yes you can do that but it will complete your sentence in Shakespeare style.
The starting character is in:
x = my_txtutils.convert_from_alphabet(ord("L"))
y=x

If you want to start from a sentence instead of a character, you will have to change these lines in the inference loop too:

c = my_txtutils.sample_from_probabilities(yo, topn=2)
y = np.array([[c]]) # shape [BATCHSIZE, SEQLEN] with BATCHSIZE=1 and SEQLEN=1

If you look at the code you will see the "y" is both the output char of the current iteration and is used as the input char to the RNN for the next iteration. In your case, you would use characters from your seed sentence as inputs into the RNN and switch back to the normal behaviour when your seed sentence is exhausted.

Tell me if it works, this could be quite fun.

@deeptibhegde
Copy link
Author

Thanks for the reply! I actually trained it on my own dataset, so it should work. I'll let you know!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants