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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 17,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [],
|
8 |
+
"source": [
|
9 |
+
"import pandas as pd\n",
|
10 |
+
"\n",
|
11 |
+
"moves = pd.read_csv(\"data/moves.csv\")\n",
|
12 |
+
"text = moves[[\"Name\", \"Effect\"]]\n",
|
13 |
+
"combined_move = text.apply(lambda x: x[\"Name\"] + \" \" + x[\"Effect\"], axis = 1).tolist()\n",
|
14 |
+
"text = ''.join(str(elem) for elem in combined_move)"
|
15 |
+
]
|
16 |
+
},
|
17 |
+
{
|
18 |
+
"cell_type": "code",
|
19 |
+
"execution_count": 29,
|
20 |
+
"metadata": {},
|
21 |
+
"outputs": [
|
22 |
+
{
|
23 |
+
"name": "stdout",
|
24 |
+
"output_type": "stream",
|
25 |
+
"text": [
|
26 |
+
"Corpus length: 82111\n",
|
27 |
+
"Total chars: 70\n",
|
28 |
+
"Number of sequences: 27357\n"
|
29 |
+
]
|
30 |
+
}
|
31 |
+
],
|
32 |
+
"source": [
|
33 |
+
"from tensorflow import keras\n",
|
34 |
+
"from tensorflow.keras import layers\n",
|
35 |
+
"\n",
|
36 |
+
"import numpy as np\n",
|
37 |
+
"import random\n",
|
38 |
+
"import io\n",
|
39 |
+
"\n",
|
40 |
+
"\n",
|
41 |
+
"\n",
|
42 |
+
"#path = keras.utils.get_file(\n",
|
43 |
+
"# \"nietzsche.txt\", origin=\"https://s3.amazonaws.com/text-datasets/nietzsche.txt\"\n",
|
44 |
+
"#)\n",
|
45 |
+
"#with io.open(path, encoding=\"utf-8\") as f:\n",
|
46 |
+
"# text = f.read().lower()\n",
|
47 |
+
"\n",
|
48 |
+
"\n",
|
49 |
+
"\n",
|
50 |
+
"#text = text.replace(\"\\n\", \" \") # We remove newlines chars for nicer display\n",
|
51 |
+
"print(\"Corpus length:\", len(text))\n",
|
52 |
+
"\n",
|
53 |
+
"chars = sorted(list(set(text)))\n",
|
54 |
+
"print(\"Total chars:\", len(chars))\n",
|
55 |
+
"char_indices = dict((c, i) for i, c in enumerate(chars))\n",
|
56 |
+
"indices_char = dict((i, c) for i, c in enumerate(chars))\n",
|
57 |
+
"\n",
|
58 |
+
"# cut the text in semi-redundant sequences of maxlen characters\n",
|
59 |
+
"maxlen = 40\n",
|
60 |
+
"step = 3\n",
|
61 |
+
"sentences = []\n",
|
62 |
+
"next_chars = []\n",
|
63 |
+
"for i in range(0, len(text) - maxlen, step):\n",
|
64 |
+
" sentences.append(text[i : i + maxlen])\n",
|
65 |
+
" next_chars.append(text[i + maxlen])\n",
|
66 |
+
"print(\"Number of sequences:\", len(sentences))\n",
|
67 |
+
"\n",
|
68 |
+
"x = np.zeros((len(sentences), maxlen, len(chars)), dtype=np.bool)\n",
|
69 |
+
"y = np.zeros((len(sentences), len(chars)), dtype=np.bool)\n",
|
70 |
+
"for i, sentence in enumerate(sentences):\n",
|
71 |
+
" for t, char in enumerate(sentence):\n",
|
72 |
+
" x[i, t, char_indices[char]] = 1\n",
|
73 |
+
" y[i, char_indices[next_chars[i]]] = 1\n",
|
74 |
+
" \n",
|
75 |
+
" \n",
|
76 |
+
" \n",
|
77 |
+
" \n",
|
78 |
+
"model = keras.Sequential(\n",
|
79 |
+
" [\n",
|
80 |
+
" keras.Input(shape=(maxlen, len(chars))),\n",
|
81 |
+
" layers.LSTM(64),\n",
|
82 |
+
" layers.Dense(len(chars), activation=\"softmax\"),\n",
|
83 |
+
" ]\n",
|
84 |
+
")\n",
|
85 |
+
"optimizer = keras.optimizers.RMSprop(learning_rate=0.01)\n",
|
86 |
+
"model.compile(loss=\"categorical_crossentropy\", optimizer=optimizer)\n",
|
87 |
+
"\n",
|
88 |
+
"\n",
|
89 |
+
"\n",
|
90 |
+
"\n",
|
91 |
+
"\n",
|
92 |
+
"def sample(preds, temperature=1.0):\n",
|
93 |
+
" # helper function to sample an index from a probability array\n",
|
94 |
+
" preds = np.asarray(preds).astype(\"float64\")\n",
|
95 |
+
" preds = np.log(preds) / temperature\n",
|
96 |
+
" exp_preds = np.exp(preds)\n",
|
97 |
+
" preds = exp_preds / np.sum(exp_preds)\n",
|
98 |
+
" probas = np.random.multinomial(1, preds, 1)\n",
|
99 |
+
" return np.argmax(probas)\n",
|
100 |
+
"\n",
|
101 |
+
"\n",
|
102 |
+
"epochs = 40\n",
|
103 |
+
"batch_size = 128\n",
|
104 |
+
"\n"
|
105 |
+
]
|
106 |
+
},
|
107 |
+
{
|
108 |
+
"cell_type": "code",
|
109 |
+
"execution_count": null,
|
110 |
+
"metadata": {},
|
111 |
+
"outputs": [
|
112 |
+
{
|
113 |
+
"name": "stdout",
|
114 |
+
"output_type": "stream",
|
115 |
+
"text": [
|
116 |
+
"214/214 [==============================] - 5s 19ms/step - loss: 2.7839\n",
|
117 |
+
"\n",
|
118 |
+
"Generating text after epoch: 0\n",
|
119 |
+
"...Diversity: 0.2\n",
|
120 |
+
"...Generating with seed: \"c Laser The user shoots powerful lasers \"\n"
|
121 |
+
]
|
122 |
+
},
|
123 |
+
{
|
124 |
+
"name": "stderr",
|
125 |
+
"output_type": "stream",
|
126 |
+
"text": [
|
127 |
+
"Exception ignored in: <function ScopedTFGraph.__del__ at 0x7f8cc8171af0>\n",
|
128 |
+
"Traceback (most recent call last):\n",
|
129 |
+
" File \"/Users/ArjunPatel/opt/anaconda3/envs/Speeko_Testing/lib/python3.8/site-packages/tensorflow/python/framework/c_api_util.py\", line 58, in __del__\n",
|
130 |
+
" self.deleter(self.graph)\n",
|
131 |
+
"AttributeError: deleter\n"
|
132 |
+
]
|
133 |
+
},
|
134 |
+
{
|
135 |
+
"name": "stdout",
|
136 |
+
"output_type": "stream",
|
137 |
+
"text": [
|
138 |
+
"...Generated: and the target the target the target target target target als als ats als ans the target the user al\n",
|
139 |
+
"\n",
|
140 |
+
"...Diversity: 0.5\n",
|
141 |
+
"...Generating with seed: \"c Laser The user shoots powerful lasers \"\n",
|
142 |
+
"...Generated: als ald ats the user s bery the target ats atd thit as atatstamas the user s whit its the target the\n",
|
143 |
+
"\n",
|
144 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 1.7724\n",
|
145 |
+
"\n",
|
146 |
+
"Generating text after epoch: 1\n",
|
147 |
+
"...Diversity: 0.2\n",
|
148 |
+
"...Generating with seed: \"he user moves after the target, this att\"\n",
|
149 |
+
"...Generated: acks the target its attacks the target its attacks the target its the target with stattack the targe\n",
|
150 |
+
"\n",
|
151 |
+
"...Diversity: 0.5\n",
|
152 |
+
"...Generating with seed: \"he user moves after the target, this att\"\n",
|
153 |
+
"...Generated: acked. This move the target ind chaske twattat. This may also damang the target with sping. This may\n",
|
154 |
+
"\n",
|
155 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 1.5458\n",
|
156 |
+
"\n",
|
157 |
+
"Generating text after epoch: 2\n",
|
158 |
+
"...Diversity: 0.2\n",
|
159 |
+
"...Generating with seed: \". If this move is used every turn, its p\"\n",
|
160 |
+
"...Generated: owers it is a cond the target with a pore on the target it is a the target with a to the target is a\n",
|
161 |
+
"\n",
|
162 |
+
"...Diversity: 0.5\n",
|
163 |
+
"...Generating with seed: \". If this move is used every turn, its p\"\n",
|
164 |
+
"...Generated: ower. This move lestock the target is hall the target with eseritical hits and and the target with a\n",
|
165 |
+
"\n",
|
166 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 1.4048\n",
|
167 |
+
"\n",
|
168 |
+
"Generating text after epoch: 3\n",
|
169 |
+
"...Diversity: 0.2\n",
|
170 |
+
"...Generating with seed: \"er quite a lot. This attack may leave th\"\n",
|
171 |
+
"...Generated: e target its stats and attack the target with sowers the target its stat and attack the target in a \n",
|
172 |
+
"\n",
|
173 |
+
"...Diversity: 0.5\n",
|
174 |
+
"...Generating with seed: \"er quite a lot. This attack may leave th\"\n",
|
175 |
+
"...Generated: e target with amand and its bect the target. This may also leave the target its stat is a resing the\n",
|
176 |
+
"\n",
|
177 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 1.3027\n",
|
178 |
+
"\n",
|
179 |
+
"Generating text after epoch: 4\n",
|
180 |
+
"...Diversity: 0.2\n",
|
181 |
+
"...Generating with seed: \"ith lightning-like movement before deliv\"\n",
|
182 |
+
"...Generated: erates that flict harses that canding Pokémon in the target. This may also leave the target with a p\n",
|
183 |
+
"\n",
|
184 |
+
"...Diversity: 0.5\n",
|
185 |
+
"...Generating with seed: \"ith lightning-like movement before deliv\"\n",
|
186 |
+
"...Generated: ent power. This may also leave the stat, that also leap and starges boising and by attack that ticen\n",
|
187 |
+
"\n",
|
188 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 1.2268\n",
|
189 |
+
"\n",
|
190 |
+
"Generating text after epoch: 5\n",
|
191 |
+
"...Diversity: 0.2\n",
|
192 |
+
"...Generating with seed: \"half the damage taken by the target.Hype\"\n",
|
193 |
+
"...Generated: ram The user target with a ponding to the target. This may also leave the target's Sp. Def stats by \n",
|
194 |
+
"\n",
|
195 |
+
"...Diversity: 0.5\n",
|
196 |
+
"...Generating with seed: \"half the damage taken by the target.Hype\"\n",
|
197 |
+
"...Generated: rasing The user staroates the target's Attack stats.Stock The user attacks the target. This may also\n",
|
198 |
+
"\n",
|
199 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 1.1595\n",
|
200 |
+
"\n",
|
201 |
+
"Generating text after epoch: 6\n",
|
202 |
+
"...Diversity: 0.2\n",
|
203 |
+
"...Generating with seed: \"ground from priority moves and powers up\"\n",
|
204 |
+
"...Generated: and the target. This may also lowers the user the target with a burn.Speed The user stats its targe\n",
|
205 |
+
"\n",
|
206 |
+
"...Diversity: 0.5\n",
|
207 |
+
"...Generating with seed: \"ground from priority moves and powers up\"\n",
|
208 |
+
"...Generated: and the target with a ponding a burn.Beap The user strakes the target. This also leave the user's a\n",
|
209 |
+
"\n",
|
210 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 1.1082\n",
|
211 |
+
"\n",
|
212 |
+
"Generating text after epoch: 7\n",
|
213 |
+
"...Diversity: 0.2\n",
|
214 |
+
"...Generating with seed: \"also leave the target with a burn.Boombu\"\n",
|
215 |
+
"...Generated: t The user attacks the target is a retack that hits into the target with ever the target is hits int\n",
|
216 |
+
"\n",
|
217 |
+
"...Diversity: 0.5\n",
|
218 |
+
"...Generating with seed: \"also leave the target with a burn.Boombu\"\n",
|
219 |
+
"...Generated: t The user attacks the target is of power is into the target is strend on the target with ever this \n",
|
220 |
+
"\n",
|
221 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 1.0621\n",
|
222 |
+
"\n",
|
223 |
+
"Generating text after epoch: 8\n",
|
224 |
+
"...Diversity: 0.2\n",
|
225 |
+
"...Generating with seed: \"erage its Attack and Sp. Atk stats with \"\n",
|
226 |
+
"...Generated: a bittle.Spore The user attacks the target with its body raising the target with its body raising th\n",
|
227 |
+
"\n",
|
228 |
+
"...Diversity: 0.5\n",
|
229 |
+
"...Generating with seed: \"erage its Attack and Sp. Atk stats with \"\n",
|
230 |
+
"...Generated: a moven the target with a burn.Streghim The user attacks the target with its bo de inflict damage.Sp\n",
|
231 |
+
"\n",
|
232 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 1.0201\n",
|
233 |
+
"\n",
|
234 |
+
"Generating text after epoch: 9\n",
|
235 |
+
"...Diversity: 0.2\n",
|
236 |
+
"...Generating with seed: \"ves that inflict status conditions are b\"\n",
|
237 |
+
"...Generated: last of the target. This may also leave the target with a blad the target. The user restores the tar\n",
|
238 |
+
"\n",
|
239 |
+
"...Diversity: 0.5\n",
|
240 |
+
"...Generating with seed: \"ves that inflict status conditions are b\"\n",
|
241 |
+
"...Generated: last of dousing.Max Smise Beam The user crounds a ceres the target's anding its opposing Pokémon in \n",
|
242 |
+
"\n",
|
243 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 0.9896\n",
|
244 |
+
"\n",
|
245 |
+
"Generating text after epoch: 10\n",
|
246 |
+
"...Diversity: 0.2\n",
|
247 |
+
"...Generating with seed: \"acker's Defense stat.Octolock The user l\"\n",
|
248 |
+
"...Generated: ays a sulleash and the target with a scathers the target. This may also leave the target with a scat\n",
|
249 |
+
"\n",
|
250 |
+
"...Diversity: 0.5\n",
|
251 |
+
"...Generating with seed: \"acker's Defense stat.Octolock The user l\"\n",
|
252 |
+
"...Generated: eve attacks the target. This may also leave the target with a status conditions the target's Attack \n",
|
253 |
+
"\n",
|
254 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 0.9533\n",
|
255 |
+
"\n",
|
256 |
+
"Generating text after epoch: 11\n",
|
257 |
+
"...Diversity: 0.2\n",
|
258 |
+
"...Generating with seed: \"user whirls its fists to send a wave of \"\n",
|
259 |
+
"...Generated: the target's damage. This may also leave the target with a bittle. This may also leave the target wi\n",
|
260 |
+
"\n",
|
261 |
+
"...Diversity: 0.5\n",
|
262 |
+
"...Generating with seed: \"user whirls its fists to send a wave of \"\n",
|
263 |
+
"...Generated: the targetts target. This may also leave the target with a powerturn that also lives a restoic to a \n",
|
264 |
+
"\n",
|
265 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 0.9264\n",
|
266 |
+
"\n",
|
267 |
+
"Generating text after epoch: 12\n",
|
268 |
+
"...Diversity: 0.2\n",
|
269 |
+
"...Generating with seed: \"by vibration. This may also lower the ta\"\n",
|
270 |
+
"...Generated: rget's Sp. Atk stat. This may also lower the target's Sp. Atk stat. This may also leave the target f\n",
|
271 |
+
"\n",
|
272 |
+
"...Diversity: 0.5\n",
|
273 |
+
"...Generating with seed: \"by vibration. This may also lower the ta\"\n",
|
274 |
+
"...Generated: rget's Attack stat. This may also lower the target's Sp. Atk stat.Mint Band The user list of powers \n",
|
275 |
+
"\n",
|
276 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 0.9027\n",
|
277 |
+
"\n",
|
278 |
+
"Generating text after epoch: 13\n",
|
279 |
+
"...Diversity: 0.2\n",
|
280 |
+
"...Generating with seed: \"er attacks by wrapping the target in fie\"\n",
|
281 |
+
"...Generated: r that boweleriting enery its boctical harshly lowers the user attacks by switched with a burn.Flarg\n",
|
282 |
+
"\n",
|
283 |
+
"...Diversity: 0.5\n",
|
284 |
+
"...Generating with seed: \"er attacks by wrapping the target in fie\"\n",
|
285 |
+
"...Generated: r to lend and Sp. Den enditics. This may also leave the target with pouses the user target with pana\n",
|
286 |
+
"\n",
|
287 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 0.8782\n",
|
288 |
+
"\n",
|
289 |
+
"Generating text after epoch: 14\n",
|
290 |
+
"...Diversity: 0.2\n",
|
291 |
+
"...Generating with seed: \"ace or eyes. This may also lower the tar\"\n",
|
292 |
+
"...Generated: get's Speed stat. This move's power is into the target with a blad conting the power of the target w\n",
|
293 |
+
"\n",
|
294 |
+
"...Diversity: 0.5\n",
|
295 |
+
"...Generating with seed: \"ace or eyes. This may also lower the tar\"\n",
|
296 |
+
"...Generated: get's Speed stat, has a bittle. This move allo es the preterf bo uned with eadoned to deal haves the\n",
|
297 |
+
"\n",
|
298 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 0.8620\n",
|
299 |
+
"\n",
|
300 |
+
"Generating text after epoch: 15\n",
|
301 |
+
"...Diversity: 0.2\n",
|
302 |
+
"...Generating with seed: \" its mind to ensure its next attack does\"\n",
|
303 |
+
"...Generated: from stats of flasts and a bid on the target. This may also leave the target with its bood the targ\n",
|
304 |
+
"\n",
|
305 |
+
"...Diversity: 0.5\n",
|
306 |
+
"...Generating with seed: \" its mind to ensure its next attack does\"\n",
|
307 |
+
"...Generated: fince of Psychic trement on the giting the ground with its Awter throwing the target's accuracy.Sig\n",
|
308 |
+
"\n",
|
309 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 0.8419\n",
|
310 |
+
"\n",
|
311 |
+
"Generating text after epoch: 16\n",
|
312 |
+
"...Diversity: 0.2\n",
|
313 |
+
"...Generating with seed: \"d icicle lance at opposing Pokémon.Grass\"\n",
|
314 |
+
"...Generated: Powd This The user attacks the target with a birsticul conting to target. This may also leave the t\n",
|
315 |
+
"\n",
|
316 |
+
"...Diversity: 0.5\n",
|
317 |
+
"...Generating with seed: \"d icicle lance at opposing Pokémon.Grass\"\n",
|
318 |
+
"...Generated: Pladow The user terns an its that really is damage powerful halstical hits.Trows The user sharply r\n",
|
319 |
+
"\n",
|
320 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 0.8232\n",
|
321 |
+
"\n",
|
322 |
+
"Generating text after epoch: 17\n",
|
323 |
+
"...Diversity: 0.2\n",
|
324 |
+
"...Generating with seed: \"ater equivalent, its power increases and\"\n",
|
325 |
+
"...Generated: restores the target with a bory hard land and heade the target with a power of the target with its \n",
|
326 |
+
"\n",
|
327 |
+
"...Diversity: 0.5\n",
|
328 |
+
"...Generating with seed: \"ater equivalent, its power increases and\"\n",
|
329 |
+
"...Generated: attackes hall the user stronsing the user haslly lowers the target with and of attacked with its st\n",
|
330 |
+
"\n",
|
331 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 0.8119\n",
|
332 |
+
"\n",
|
333 |
+
"Generating text after epoch: 18\n",
|
334 |
+
"...Diversity: 0.2\n",
|
335 |
+
"...Generating with seed: \"sappears.Skill Swap The user employs its\"\n",
|
336 |
+
"...Generated: poising a stat ally Pokémon a move tire ally Pokémon use. The user throws a seally poisonsuse. This\n",
|
337 |
+
"\n",
|
338 |
+
"...Diversity: 0.5\n",
|
339 |
+
"...Generating with seed: \"sappears.Skill Swap The user employs its\"\n",
|
340 |
+
"...Generated: target with a pitended with a powerfles and attacks it it is heal attack the target. The user throw\n",
|
341 |
+
"\n",
|
342 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 0.7990\n",
|
343 |
+
"\n",
|
344 |
+
"Generating text after epoch: 19\n",
|
345 |
+
"...Diversity: 0.2\n",
|
346 |
+
"...Generating with seed: \" inflict damage.Vise Grip The target is \"\n",
|
347 |
+
"...Generated: attacked with its to five times in a row. Its attack hits with a bide tirn for for the user target f\n",
|
348 |
+
"\n",
|
349 |
+
"...Diversity: 0.5\n",
|
350 |
+
"...Generating with seed: \" inflict damage.Vise Grip The target is \"\n",
|
351 |
+
"...Generated: attacked with its swown drentical hit hits the target with its to five times in a refloce is dre pow\n",
|
352 |
+
"\n",
|
353 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 0.7890\n",
|
354 |
+
"\n",
|
355 |
+
"Generating text after epoch: 20\n",
|
356 |
+
"...Diversity: 0.2\n",
|
357 |
+
"...Generating with seed: \"t-draining attack. The user's HP is rest\"\n",
|
358 |
+
"...Generated: ored by harget flinch. The user attacks the target with a bide tirn of the target. This may also lea\n",
|
359 |
+
"\n",
|
360 |
+
"...Diversity: 0.5\n",
|
361 |
+
"...Generating with seed: \"t-draining attack. The user's HP is rest\"\n",
|
362 |
+
"...Generated: ored for five turns. Pulp of lay inds a crount of a nefffoce ally Pokémon in the target. This may al\n",
|
363 |
+
"\n",
|
364 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 0.7800\n",
|
365 |
+
"\n",
|
366 |
+
"Generating text after epoch: 21\n",
|
367 |
+
"...Diversity: 0.2\n",
|
368 |
+
"...Generating with seed: \"s of the listening opposing Pokémon. Thi\"\n",
|
369 |
+
"...Generated: s may also leave the target with a power of fall a concering the target with a power of fall a conce\n",
|
370 |
+
"\n",
|
371 |
+
"...Diversity: 0.5\n",
|
372 |
+
"...Generating with seed: \"s of the listening opposing Pokémon. Thi\"\n",
|
373 |
+
"...Generated: s may also leave the target with a power is damage the user tarleboches the target is a pulf fint th\n",
|
374 |
+
"\n",
|
375 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 0.7695\n",
|
376 |
+
"\n",
|
377 |
+
"Generating text after epoch: 22\n",
|
378 |
+
"...Diversity: 0.2\n",
|
379 |
+
"...Generating with seed: \"ways results in a critical hit.Leech See\"\n",
|
380 |
+
"...Generated: d The user attacks the target with its to five tires the target with a bit by hit makes the target w\n",
|
381 |
+
"\n",
|
382 |
+
"...Diversity: 0.5\n",
|
383 |
+
"...Generating with seed: \"ways results in a critical hit.Leech See\"\n",
|
384 |
+
"...Generated: d The user triches eces a beady the target with its Attack stat.Ligh Bear The user cunse stats itsel\n",
|
385 |
+
"\n",
|
386 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 0.7558\n",
|
387 |
+
"\n",
|
388 |
+
"Generating text after epoch: 23\n",
|
389 |
+
"...Diversity: 0.2\n",
|
390 |
+
"...Generating with seed: \"a shock wave generated by the user's gap\"\n",
|
391 |
+
"...Generated: s aint move to raise in the target. The user throws of its bocy ally Pokémon. This may also lower th\n",
|
392 |
+
"\n",
|
393 |
+
"...Diversity: 0.5\n",
|
394 |
+
"...Generating with seed: \"a shock wave generated by the user's gap\"\n",
|
395 |
+
"...Generated: s and Sp. Def stats.Councheshes The user throws a status conditions. This may also lower the target'\n",
|
396 |
+
"\n",
|
397 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 0.7477\n",
|
398 |
+
"\n",
|
399 |
+
"Generating text after epoch: 24\n",
|
400 |
+
"...Diversity: 0.2\n",
|
401 |
+
"...Generating with seed: \". When used with its water equivalent, i\"\n",
|
402 |
+
"...Generated: ts bottring its attack for power. The user terns its stees a coilly and stats with a powerflly gite \n",
|
403 |
+
"\n",
|
404 |
+
"...Diversity: 0.5\n",
|
405 |
+
"...Generating with seed: \". When used with its water equivalent, i\"\n",
|
406 |
+
"...Generated: ts body, the target from sweed flomes to half into Wlldes of the target. This may also lower the tar\n",
|
407 |
+
"\n",
|
408 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 0.7382\n",
|
409 |
+
"\n",
|
410 |
+
"Generating text after epoch: 25\n",
|
411 |
+
"...Diversity: 0.2\n",
|
412 |
+
"...Generating with seed: \"ift The user swaps its offensive and def\"\n",
|
413 |
+
"...Generated: elects and a dreat the plach ally Pokémon. This may also leave the target with a burn.Flare Blast Th\n",
|
414 |
+
"\n",
|
415 |
+
"...Diversity: 0.5\n",
|
416 |
+
"...Generating with seed: \"ift The user swaps its offensive and def\"\n",
|
417 |
+
"...Generated: levs confeates itself and puter that cantacterive itself and pptattacely, has beternstoring the powe\n",
|
418 |
+
"\n",
|
419 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 0.7358\n",
|
420 |
+
"\n",
|
421 |
+
"Generating text after epoch: 26\n",
|
422 |
+
"...Diversity: 0.2\n",
|
423 |
+
"...Generating with seed: \"g its attack, the user rushes back to sw\"\n",
|
424 |
+
"...Generated: itched in a raging the target to attack.Scles The user attacks the target with its move's power.Coar\n",
|
425 |
+
"\n",
|
426 |
+
"...Diversity: 0.5\n",
|
427 |
+
"...Generating with seed: \"g its attack, the user rushes back to sw\"\n",
|
428 |
+
"...Generated: itch.Loubler Smot The user attacks the target with its a target flyies to for fron stat lughes with \n",
|
429 |
+
"\n",
|
430 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 0.7275\n",
|
431 |
+
"\n",
|
432 |
+
"Generating text after epoch: 27\n",
|
433 |
+
"...Diversity: 0.2\n",
|
434 |
+
"...Generating with seed: \"onents.G-Max Cannonade A Water-type atta\"\n",
|
435 |
+
"...Generated: ck that Gigantamax Guard The user sharply raises the user gathess dowe s at the target. This may als\n",
|
436 |
+
"\n",
|
437 |
+
"...Diversity: 0.5\n",
|
438 |
+
"...Generating with seed: \"onents.G-Max Cannonade A Water-type atta\"\n",
|
439 |
+
"...Generated: ck that Gigand move canged a target. This may also power or Densends the target.Sweel Anger the user\n",
|
440 |
+
"\n",
|
441 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 0.7256\n",
|
442 |
+
"\n",
|
443 |
+
"Generating text after epoch: 28\n",
|
444 |
+
"...Diversity: 0.2\n",
|
445 |
+
"...Generating with seed: \" last.Copycat The user mimics the move u\"\n",
|
446 |
+
"...Generated: se. This move also lowers the target's Sp. Def stat.Max Sweed This move attack on the target with it\n",
|
447 |
+
"\n",
|
448 |
+
"...Diversity: 0.5\n",
|
449 |
+
"...Generating with seed: \" last.Copycat The user mimics the move u\"\n",
|
450 |
+
"...Generated: se. This move also lespowers and restares the target. This may also lowers the target's Speed stat. \n",
|
451 |
+
"\n",
|
452 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 0.7123\n",
|
453 |
+
"\n",
|
454 |
+
"Generating text after epoch: 29\n",
|
455 |
+
"...Diversity: 0.2\n",
|
456 |
+
"...Generating with seed: \"gears to raise the Attack and Sp. Atk st\"\n",
|
457 |
+
"...Generated: at.ear Storm The user attacks with a burn.Storm The user attacks with a burn.Flaraly The user attack\n",
|
458 |
+
"\n",
|
459 |
+
"...Diversity: 0.5\n",
|
460 |
+
"...Generating with seed: \"gears to raise the Attack and Sp. Atk st\"\n",
|
461 |
+
"...Generated: at cantices fire drensot the target with a burn.starge Areasive purp of cangelensing the target with\n",
|
462 |
+
"\n",
|
463 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 0.7158\n",
|
464 |
+
"\n",
|
465 |
+
"Generating text after epoch: 30\n",
|
466 |
+
"...Diversity: 0.2\n",
|
467 |
+
"...Generating with seed: \"em becomes burned up and unusable.Infern\"\n",
|
468 |
+
"...Generated: Push The user attacks with a powerfur that moves the target with a burn.Flare Punch The user attack\n",
|
469 |
+
"\n",
|
470 |
+
"...Diversity: 0.5\n",
|
471 |
+
"...Generating with seed: \"em becomes burned up and unusable.Infern\"\n",
|
472 |
+
"...Generated: se The user hallstokss in hears boto inflict damage. This may also power om its power.Pounche The us\n",
|
473 |
+
"\n",
|
474 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 0.7057\n",
|
475 |
+
"\n",
|
476 |
+
"Generating text after epoch: 31\n",
|
477 |
+
"...Diversity: 0.2\n",
|
478 |
+
"...Generating with seed: \" the next turn.Spark The user throws an \"\n",
|
479 |
+
"...Generated: engathin by a misle. This may also make the target with a nerys.Tax SwPeckif The user strokss the ta\n",
|
480 |
+
"\n",
|
481 |
+
"...Diversity: 0.5\n",
|
482 |
+
"...Generating with seed: \" the next turn.Spark The user throws an \"\n",
|
483 |
+
"...Generated: ond the target with its target in a row.Cuess A stat usted. This may also make the target with a bur\n",
|
484 |
+
"\n",
|
485 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 0.6976\n",
|
486 |
+
"\n",
|
487 |
+
"Generating text after epoch: 32\n",
|
488 |
+
"...Diversity: 0.2\n",
|
489 |
+
"...Generating with seed: \"ack Dynamax Pokémon use. This raises all\"\n",
|
490 |
+
"...Generated: of its mance the target. This also lowers the target's Speed stat.Ston Spoed At the user attacks th\n",
|
491 |
+
"\n",
|
492 |
+
"...Diversity: 0.5\n",
|
493 |
+
"...Generating with seed: \"ack Dynamax Pokémon use. This raises all\"\n",
|
494 |
+
"...Generated: y Pokémon in the target, andick and a dist the target. This also leaves the target's Defense s attac\n",
|
495 |
+
"\n",
|
496 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 0.6968\n",
|
497 |
+
"\n",
|
498 |
+
"Generating text after epoch: 33\n",
|
499 |
+
"...Diversity: 0.2\n",
|
500 |
+
"...Generating with seed: \"what they were.Torment The user torments\"\n",
|
501 |
+
"...Generated: owe thrown to the target to a target into the target with its storm of falling this move in skgeste\n",
|
502 |
+
"\n",
|
503 |
+
"...Diversity: 0.5\n",
|
504 |
+
"...Generating with seed: \"what they were.Torment The user torments\"\n",
|
505 |
+
"...Generated: or forlly, the user uses the target with a scill of scap at opposing Pokémon. This may also leave t\n",
|
506 |
+
"\n",
|
507 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 0.6933\n",
|
508 |
+
"\n",
|
509 |
+
"Generating text after epoch: 34\n",
|
510 |
+
"...Diversity: 0.2\n",
|
511 |
+
"...Generating with seed: \"y Face The user frightens the target wit\"\n",
|
512 |
+
"...Generated: h a power of the target. This may also leave the target with a burn.Flare Blast The user attacks wit\n",
|
513 |
+
"\n",
|
514 |
+
"...Diversity: 0.5\n",
|
515 |
+
"...Generating with seed: \"y Face The user frightens the target wit\"\n",
|
516 |
+
"...Generated: h a burn.sound A supl to dearge drespict its stat ines.lariPs Guace of its bottringing and throus da\n",
|
517 |
+
"\n",
|
518 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 0.6860\n",
|
519 |
+
"\n",
|
520 |
+
"Generating text after epoch: 35\n",
|
521 |
+
"...Diversity: 0.2\n",
|
522 |
+
"...Generating with seed: \"igantamax Pikachu use. This move paralyz\"\n",
|
523 |
+
"...Generated: e dokémon the target with its own on the target with its offentical parions.Coak The user attacks wh\n",
|
524 |
+
"\n",
|
525 |
+
"...Diversity: 0.5\n",
|
526 |
+
"...Generating with seed: \"igantamax Pikachu use. This move paralyz\"\n",
|
527 |
+
"...Generated: es the fire used it its move's power. This may also lower the target's Sp. Def stat.Shell Swap The u\n",
|
528 |
+
"\n",
|
529 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 0.6901\n",
|
530 |
+
"\n",
|
531 |
+
"Generating text after epoch: 36\n",
|
532 |
+
"...Diversity: 0.2\n",
|
533 |
+
"...Generating with seed: \" move enables the user to protect itself\"\n",
|
534 |
+
"...Generated: attack with a burn.Flare Blast The user attacks with a burn.Flare Blast The user attacks by wroppin\n",
|
535 |
+
"\n",
|
536 |
+
"...Diversity: 0.5\n",
|
537 |
+
"...Generating with seed: \" move enables the user to protect itself\"\n",
|
538 |
+
"...Generated: of inflaces if its bovy raises attack with its target with paracyone the target is and flaces if it\n",
|
539 |
+
"\n",
|
540 |
+
"214/214 [==============================] - 4s 19ms/step - loss: 0.6785\n",
|
541 |
+
"\n",
|
542 |
+
"Generating text after epoch: 37\n",
|
543 |
+
"...Diversity: 0.2\n",
|
544 |
+
"...Generating with seed: \"he user has no PP. It also damages the u\"\n",
|
545 |
+
"...Generated: ser attacks the target with a burn.Trick Sheek The user strikes its target with a burn.Tric Punch Th\n",
|
546 |
+
"\n",
|
547 |
+
"...Diversity: 0.5\n",
|
548 |
+
"...Generating with seed: \"he user has no PP. It also damages the u\"\n",
|
549 |
+
"...Generated: ser attacks with a poinct of its max mond of flaist an a redred the ground in the target. The user's\n",
|
550 |
+
"\n",
|
551 |
+
"214/214 [==============================] - 5s 25ms/step - loss: 0.6760\n",
|
552 |
+
"\n",
|
553 |
+
"Generating text after epoch: 38\n",
|
554 |
+
"...Diversity: 0.2\n",
|
555 |
+
"...Generating with seed: \"to exchange Abilities with the target.Sl\"\n",
|
556 |
+
"...Generated: edp A stat usters attack types attack that harshes with a burn.Storm The user attacks the target wit\n",
|
557 |
+
"\n",
|
558 |
+
"...Diversity: 0.5\n",
|
559 |
+
"...Generating with seed: \"to exchange Abilities with the target.Sl\"\n",
|
560 |
+
"...Generated: edp A stat usterned, the user attacks the target with eapopeatep to attat flome the by throus blad o\n",
|
561 |
+
"\n",
|
562 |
+
"214/214 [==============================] - 5s 21ms/step - loss: 0.6674\n",
|
563 |
+
"\n",
|
564 |
+
"Generating text after epoch: 39\n",
|
565 |
+
"...Diversity: 0.2\n",
|
566 |
+
"...Generating with seed: \"age on opposing Pokémon.Shock Wave The u\"\n",
|
567 |
+
"...Generated: ser strikes itself of the target with a pay also make the target with a pay also make the target wit\n",
|
568 |
+
"\n",
|
569 |
+
"...Diversity: 0.5\n",
|
570 |
+
"...Generating with seed: \"age on opposing Pokémon.Shock Wave The u\"\n",
|
571 |
+
"...Generated: ser excls a neritical hits.Swetress The user swimser, the target's Attack stat buce into the target.\n",
|
572 |
+
"\n"
|
573 |
+
]
|
574 |
+
}
|
575 |
+
],
|
576 |
+
"source": [
|
577 |
+
"for epoch in range(epochs):\n",
|
578 |
+
" model.fit(x, y, batch_size=batch_size, epochs=1)\n",
|
579 |
+
" print()\n",
|
580 |
+
" print(\"Generating text after epoch: %d\" % epoch)\n",
|
581 |
+
"\n",
|
582 |
+
" start_index = random.randint(0, len(text) - maxlen - 1)\n",
|
583 |
+
" for diversity in [0.2, 0.5]:\n",
|
584 |
+
" print(\"...Diversity:\", diversity)\n",
|
585 |
+
"\n",
|
586 |
+
" generated = \"\"\n",
|
587 |
+
" sentence = text[start_index : start_index + maxlen]\n",
|
588 |
+
" #sentence = \"Surging Strikes\"\n",
|
589 |
+
" print('...Generating with seed: \"' + sentence + '\"')\n",
|
590 |
+
"\n",
|
591 |
+
" for i in range(100):\n",
|
592 |
+
" x_pred = np.zeros((1, maxlen, len(chars)))\n",
|
593 |
+
" for t, char in enumerate(sentence):\n",
|
594 |
+
" x_pred[0, t, char_indices[char]] = 1.0\n",
|
595 |
+
" preds = model.predict(x_pred, verbose=0)[0]\n",
|
596 |
+
" next_index = sample(preds, diversity)\n",
|
597 |
+
" next_char = indices_char[next_index]\n",
|
598 |
+
" sentence = sentence[1:] + next_char\n",
|
599 |
+
" generated += next_char\n",
|
600 |
+
"\n",
|
601 |
+
" print(\"...Generated: \", generated)\n",
|
602 |
+
" print()"
|
603 |
+
]
|
604 |
+
},
|
605 |
+
{
|
606 |
+
"cell_type": "code",
|
607 |
+
"execution_count": 15,
|
608 |
+
"metadata": {},
|
609 |
+
"outputs": [],
|
610 |
+
"source": [
|
611 |
+
"path = keras.utils.get_file(\n",
|
612 |
+
" \"nietzsche.txt\", origin=\"https://s3.amazonaws.com/text-datasets/nietzsche.txt\"\n",
|
613 |
+
")\n",
|
614 |
+
"with io.open(path, encoding=\"utf-8\") as f:\n",
|
615 |
+
" text = f.read().lower()\n",
|
616 |
+
"\n",
|
617 |
+
"\n",
|
618 |
+
"\n",
|
619 |
+
"text = text.replace(\"\\n\", \" \") # We remove newlines chars for nicer display"
|
620 |
+
]
|
621 |
+
},
|
622 |
+
{
|
623 |
+
"cell_type": "code",
|
624 |
+
"execution_count": null,
|
625 |
+
"metadata": {},
|
626 |
+
"outputs": [],
|
627 |
+
"source": []
|
628 |
+
}
|
629 |
+
],
|
630 |
+
"metadata": {
|
631 |
+
"kernelspec": {
|
632 |
+
"display_name": "Python 3",
|
633 |
+
"language": "python",
|
634 |
+
"name": "python3"
|
635 |
+
},
|
636 |
+
"language_info": {
|
637 |
+
"codemirror_mode": {
|
638 |
+
"name": "ipython",
|
639 |
+
"version": 3
|
640 |
+
},
|
641 |
+
"file_extension": ".py",
|
642 |
+
"mimetype": "text/x-python",
|
643 |
+
"name": "python",
|
644 |
+
"nbconvert_exporter": "python",
|
645 |
+
"pygments_lexer": "ipython3",
|
646 |
+
"version": "3.8.3"
|
647 |
+
}
|
648 |
+
},
|
649 |
+
"nbformat": 4,
|
650 |
+
"nbformat_minor": 4
|
651 |
+
}
|