Created
July 1, 2021 12:31
-
-
Save lazuxd/f296cab1bec0f877150bb91a6fd06eae 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
def sample(self) -> str: | |
# sample a new sentence from the learned model | |
sentence = '' | |
a = np.zeros((1, self.a_size)) | |
x = np.zeros((1, self.vocab_size)) | |
while True: | |
a, y_hat = self(a, x) | |
word = sample_word(self.vocab, tf.reshape(y_hat, (-1,))) | |
if word == EOS: | |
break | |
sentence += ' '+word | |
x = words2onehot(self.vocab, [word]) | |
return sentence[1:] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment