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