()
| 215 | rnn.save('RNN_D30_M30_epochs2000_relu.npz') |
| 216 | |
| 217 | def generate_poetry(): |
| 218 | sentences, word2idx = get_robert_frost() |
| 219 | rnn = SimpleRNN.load('RNN_D30_M30_epochs2000_relu.npz', T.nnet.relu) |
| 220 | |
| 221 | # determine initial state distribution for starting sentences |
| 222 | V = len(word2idx) |
| 223 | pi = np.zeros(V) |
| 224 | for sentence in sentences: |
| 225 | pi[sentence[0]] += 1 |
| 226 | pi /= pi.sum() |
| 227 | |
| 228 | rnn.generate(pi, word2idx) |
| 229 | |
| 230 | def wikipedia(): |
| 231 | sentences, word2idx = get_wikipedia_data() |
no test coverage detected