Skip to content

Avarel/Lovecraft-LSTM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lovecraft-LSTM

A machine learning (Tensorflow) program that generates Lovecraftian horrors for your horror obsession with the old gods, who will remake this world in their image when they awake from their slumber. Based on this tutorial on LSTMs.

Tensorflow Model

_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
embedding (Embedding)        (64, None, 256)           24064     
_________________________________________________________________
dropout (Dropout)            (64, None, 256)           0         
_________________________________________________________________
lstm (LSTM)                  (64, None, 4096)          71319552  
_________________________________________________________________
dropout_1 (Dropout)          (64, None, 4096)          0         
_________________________________________________________________
lstm_1 (LSTM)                (64, None, 4096)          134234112 
_________________________________________________________________
dropout_2 (Dropout)          (64, None, 4096)          0         
_________________________________________________________________
dense (Dense)                (64, None, 94)            385118    
=================================================================
Total params: 205,962,846
Trainable params: 205,962,846
Non-trainable params: 0
_________________________________________________________________

Instructions

Setting Up the Code

Local Machine

  • Clone the repository into your local machine.

Google Colaboratory

  • Upload the training and validation text files.
    • Compress the contents of the project into a .zip and extract using the following command on the kernel.
      • !unzip -o "./Archive.zip" -d "./"
  • Set up the journal to use the correct Tensorflow version and beg the Google lords to allow you to use their Nvidia Tesla P100 GPUs.
    • Add the following into the kernel:
         try:
             %tensorflow_version 2.x
         except Exception:
             pass
         !pip install tensorflow-gpu```
  • Copy the code from ./main.py over to a code block.
  • Run the code block.

Running the Code

Local Machine

  • Unless you have a strong GPU for machine learning, good luck.
  • You can, however, download a checkpoint and generate text with it. In that case, you can read the dataset, build a model, load the weights, and generate the text with the Google Colaboratory instructions.

Google Colaboratory

For each of the desired tasks, type the following code blocks into code cells on the notebook and execute.

Reading the Dataset

import ml_data
vocab_len, char2int, int2char, tr_dataset, val_dataset = ml_data.get_datasets(batch_size)

Building the Model

import ml
model = ml.build_model(
    vocab_len,
    embedding_dim,
    rnn_units,
    batch_size
)

Training the Model

import ml
ml.train_model(model, tr_dataset, val_dataset, checkpoint_dir)

Resuming from a Checkpoint

import ml
import tensorflow as tf
model.load_weights(tf.train.latest_checkpoint(checkpoint_dir))

Generating Text with the Model

import ml
ml.generate_text(model, char2int, int2char, "the deep dark")

Downloading Checkpoints

Use the following lines.

from google.colab import files
files.download('./checkpoints/cp_x/checkpoint') 
files.download('./checkpoints/cp_x/ckpt.index') 
files.download('./checkpoints/cp_x/ckpt.data-00000-of-00002') 
files.download('./checkpoints/cp_x/ckpt.data-00001-of-00002') 

Downloading Large Checkpoint Files

Mount your Google Drive.

from google.colab import drive
drive.mount('/content/drive/')

Copy the file to the drive.

!cp './checkpoints/cp_x/ckpt.data-00001-of-00002' './drive/My Drive/ckpt.data-00001-of-00002'

Sit pretty and wait until the file appears in the Google Drive, then download it.

Sample

Check out the text generated by these various seeds.

The Deep Dark

He has made near place for the last fate in it and was only colour all alone, unhealthily arvastic psy head or frequent reading it somewhat that he could have lost every feet. And so thick chousing their swarm spsculation could where Weeden was an obloud tale, then with a summariline portal, to such a mind, far assailed could watching those beorse was nothing very less to leaunt itself. When he but well that his non-motion through the round sothothother of Shepper Mountain, which is hardly confined by many. As a last bluster, owner prevented it unimpairingly alone to Arkham; nightmare and large yawning, one appeared to branciest creatures, I saw now from unthey could not hope to regard off into the hauntry and stones and it thrive to the aunterial lands. All, however, they had been widely a few stary took my breath of so. Psaffered river itself. Now, he felt like the aattoe could do nothing ever so near before.

The Sunken City

The composerioned paths, and lower knowledge they finally reached the aid. All along two hours he had read of him, and about the ghouls which had become descended from the nightmare will toward every momentary torch and soft table afterward at the soil worked much of the little Members of 1843, when new or eighthe first clutch of a sining towers of Tsath had been oblieedly eager to something. Ear says, they did not enephe equally viccount now,, or its horrible gaped gates, and matters later, whiskeyed what closely heir towns, and were learnt unwholesome white and saved Things from the light. President of Sadephans resolved to think of me, and Were I had very dark and discovered at all. Like the other antarctic conversation was poignant to effect, and he could remain from time and wane or years that I went, probably have been two of the period, from medioin were of text in waiting at the fireless skulls or recopererme, leaving anyone of Carter, but because of the somewhat youth of...

Cthulhu

Try 1

I clung up the loss of the gorgeous fire, and as he found myself alarmed at the angle of eaco as a fore and a final succession. Of the half-human action farther some kind. With the long bulbs he noted it as now, curving, advanced fear disappeared. My mother forced metal in a journey at Bondl.

At this fearsome time and crumbling rat them were despite the full under animal for iarr a radical rubies with the fireplace. But the slum but for revealing these tested steps temperamental, the otherwise forgotten meaning that both her back with many ether and dibbing-ground.

Close hideous conversation letters, true, and the water at descent visit as a noise strange, followed but inside the rumour from the grame, bodied roof terrors and need to glimpse the horror which seemed no inferior peaks as beyond the road lay beyond their real touch in the terrain pressure that favoured and management.

Then, when the harbour walls being formed difficulty, troaseless long and curved...

Try 2

And which they quite encountered a while it towering. Ever in the bangerous energy—too developed a nameless body—though he heard a flair of immensity from the tearing beneath the very long-fear they rumbled out; so that the ghouls had just watched his eyes, till no echeerent forbadden stone on the heavy North Curwen nearing, now he wished to be the new, item was tonse departure I helped like a raftar beneath their cholibility, while our sentinels were fnancified; but I returned to such until the terrible sard; some of though all these strange frigrement we allowed to sane from theirs in question, eccentric equipment to the Great Bore intrassed obsorities for short in surprisingly meaningless and unimbried cuphist, written outlines alone at the rays the class him the onyx of the land of Erich Danic. . . . Shy’d Heaven? . . . Don’t need be the surviving that their endless twas no later, for there were lingering his meat because of this important journey, and with a caparity as if as the

Try 3

Some clothes, but that they had always placed it. We lasted mentionable, and party in the daemoniac letter with the cavecaoin reticence; but of course, henring away in great antarctic plates, carminuous gulfs in its frantic, winding, distant terrible bands from a generous reef, and did not open with some case at his roga and kin. Some abandoned element could not appear out, the noiseless rhan with the inner cloud on the lightning, he made with terrestrial execution to the carvings and dressings a monstrous thing to connect the taste, save evidently geologically library sprawling and the wounds, under bed by Zann! There now flashed up dimly—and there was all to be different dark and frightened his physician, irentifying colleagues. The its more colonial temple walk liquid to leave Leng down to Stay Friday of Ulthar, which no longer, no got away again his beneath the nameless boundless temple of New England, Parisla, and thought he could not remain here and then.

The Old Ones

At hair Late in Miskatonic Manuscript and the archiva near manifestations leading to my readen to the Las, and Obade with the words had worler the return of the locality of the bowl had been there could be Nyarlathotep and low because in all right, but the reporting soluries had perdened my work, and the litten cities were not men of some sort of nose partherly respective events of primordial family, our new light had formerly picked the Bushes and in the manoeumous single pain to me? Our machete-world about the mistake accompanieth tended to rouse trans-illustrated abysses beyond a quality of naceless moper. “Carter had driven through the now wes fastened elcelled—black candles on the other level of mystery. All-one spone blfwed, lurking sheltered Market Sypell monsters to the black. It used to take a great cities of small dreamers and a night-gaunt in the cointinguishable world benired out. But there was to discover into his purpose with early air. Barnagantic rooms were trafti

About

Tensorflow LSTM machine learning to generate texts based on Lovecraft.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages