Skip to content

Instantly share code, notes, and snippets.

@naiveHobo
Last active April 4, 2019 11:41
Show Gist options
  • Save naiveHobo/30938141441351bcdecbcb6ed81eba6a to your computer and use it in GitHub Desktop.
Save naiveHobo/30938141441351bcdecbcb6ed81eba6a to your computer and use it in GitHub Desktop.
Rick And Morty Scene Generation
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Generating Rick and Morty scripts \n",
"### Using deep learning and natural language processing"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We will first import the dependencies required to process our data and build our model"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import pickle\n",
"import numpy as np\n",
"from collections import Counter\n",
"from gensim.models import Word2Vec\n",
"\n",
"import torch\n",
"import torch.nn as nn\n",
"from torch.utils.data import Dataset\n",
"from torch.utils.data import DataLoader\n",
"from tensorboardX import SummaryWriter"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Recurrent Neural Networks are pretty heavy and ideally you would want to train your RNNs on a GPU"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"train_on_gpu = torch.cuda.is_available()\n",
"if not train_on_gpu:\n",
" print('No GPU found. Training will happen on CPU and may take a long time.')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Vocabulary\n",
"Since we are training a word-level RNN, we first need to create a vocabulary of words that our model will use. This vocabulary is built using the words present in out training data.\n",
"\n",
"We replace all punctuation with corresponding tokens for better processing of our text data."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"class Vocabulary(object):\n",
" \"\"\"\n",
" Wrapper class for vocabulary\n",
" \"\"\"\n",
"\n",
" def __init__(self):\n",
" self._word2idx = {}\n",
" self._idx2word = {}\n",
" self._counter = Counter()\n",
" self._size = 0\n",
" self._punctuation2token = {';': \"<semicolon>\",\n",
" ':': \"<colon>\",\n",
" \"'\": \"<inverted_comma>\",\n",
" '\"': \"<quotation_mark>\",\n",
" ',': \"<comma>\",\n",
" '\\n': \"<new_line>\",\n",
" '!': \"<exclamation_mark>\",\n",
" '-': \"<hyphen>\",\n",
" '--': \"<hyphens>\",\n",
" '.': \"<period>\",\n",
" '?': \"<question_mark>\",\n",
" '(': \"<left_paren>\",\n",
" ')': \"<right_paren>\",\n",
" '♪': \"<music_note>\",\n",
" '[': \"<left_square>\",\n",
" ']': \"<right_square>\",\n",
" \"’\": \"<inverted_comma>\",\n",
" }\n",
" self.add_text('<pad>')\n",
" self.add_text('<unknown>')\n",
"\n",
" def add_word(self, word):\n",
" \"\"\"\n",
" Adds a token to the vocabulary\n",
" :param word: (str) word to add to vocabulary\n",
" :return: None\n",
" \"\"\"\n",
" word = word.lower()\n",
" if word not in self._word2idx:\n",
" self._idx2word[self._size] = word\n",
" self._word2idx[word] = self._size\n",
" self._size += 1\n",
" self._counter[word] += 1\n",
"\n",
" def add_text(self, text):\n",
" \"\"\"\n",
" Splits text into tokens and adds to the vocabulary\n",
" :param text: (str) text to add to vocabulary\n",
" :return: None\n",
" \"\"\"\n",
" text = self.clean_text(text)\n",
" tokens = self.tokenize(text)\n",
" for token in tokens:\n",
" self.add_word(token)\n",
"\n",
" def clean_text(self, text):\n",
" \"\"\"\n",
" Cleans text for processing\n",
" :param text: (str) text to be cleaned\n",
" :return: (str) cleaned text\n",
" \"\"\"\n",
" text = text.lower().strip()\n",
" for key, token in self._punctuation2token.items():\n",
" text = text.replace(key, ' {} '.format(token))\n",
" text = text.strip()\n",
" while ' ' in text:\n",
" text = text.replace(' ', ' ')\n",
" return text\n",
"\n",
" def tokenize(self, text):\n",
" \"\"\"\n",
" Splits text into individual tokens\n",
" :param text: (str) text to be tokenized\n",
" :return: (list) list of tokens in text\n",
" \"\"\"\n",
" return text.split(' ')\n",
"\n",
" def set_vocab(self, vocab):\n",
" self._word2idx = {}\n",
" self._idx2word = {}\n",
" self._counter = Counter()\n",
" self._size = 0\n",
" self.add_text('<pad>')\n",
" self.add_text('<unknown>')\n",
" for word in vocab:\n",
" self.add_word(word)\n",
" \n",
" def most_common(self, n):\n",
" \"\"\"\n",
" Creates a new vocabulary object containing the n most frequent tokens from current vocabulary\n",
" :param n: (int) number of most frequent tokens to keep\n",
" :return: (Vocabulary) vocabulary containing n most frequent tokens\n",
" \"\"\"\n",
" tmp = Vocabulary()\n",
" for w in self._counter.most_common(n):\n",
" tmp.add_word(w[0])\n",
" tmp._counter[w[0]] = w[1]\n",
" return tmp\n",
"\n",
" def load(self, path='vocab.pkl'):\n",
" \"\"\"\n",
" Loads vocabulary from given path\n",
" :param path: (str) path to pkl object\n",
" :return: None\n",
" \"\"\"\n",
" with open(path, 'rb') as f:\n",
" self.__dict__.clear()\n",
" self.__dict__.update(pickle.load(f))\n",
" print(\"\\nVocabulary successfully loaded from [{}]\\n\".format(path))\n",
"\n",
" def save(self, path='vocab.pkl'):\n",
" \"\"\"\n",
" Saves vocabulary to given path\n",
" :param path: (str) path where vocabulary should be stored\n",
" :return: None\n",
" \"\"\"\n",
" with open(path, 'wb') as f:\n",
" pickle.dump(self.__dict__, f)\n",
" print(\"\\nVocabulary successfully stored as [{}]\\n\".format(path))\n",
"\n",
" def add_punctuation(self, text):\n",
" \"\"\"\n",
" Replces punctuation tokens with corresponding characters\n",
" :param text: (str) text to process\n",
" :return: text with punctuation tokens replaced with characters\n",
" \"\"\"\n",
" for key, token in self._punctuation2token.items():\n",
" text = text.replace(token, ' {} '.format(key))\n",
" text = text.strip()\n",
" while ' ' in text:\n",
" text = text.replace(' ', ' ')\n",
" text = text.replace(' :', ':')\n",
" text = text.replace(\" ' \", \"'\")\n",
" text = text.replace(\"[ \", \"[\")\n",
" text = text.replace(\" ]\", \"]\")\n",
" text = text.replace(\" .\", \".\")\n",
" text = text.replace(\" ,\", \",\")\n",
" text = text.replace(\" !\", \"!\")\n",
" text = text.replace(\" ?\", \"?\")\n",
" text = text.replace(\" ’ \", \"’\")\n",
" return text\n",
"\n",
" def __len__(self):\n",
" \"\"\"\n",
" Number of unique words in vocabulary\n",
" \"\"\"\n",
" return self._size\n",
"\n",
" def __str__(self):\n",
" s = \"Vocabulary contains {} tokens\\nMost frequent tokens:\\n\".format(self._size)\n",
" for w in self._counter.most_common(10):\n",
" s += \"{} : {}\\n\".format(w[0], w[1])\n",
" return s\n",
"\n",
" def __getitem__(self, item):\n",
" \"\"\"\n",
" Returns the word corresponding to an id or and id corresponding to a word in the vocabulary.\n",
" Return <unknown> if id/word is not present in the vocabulary\n",
" \"\"\"\n",
" if isinstance(item, int):\n",
" return self._idx2word[item]\n",
" elif isinstance(item, str):\n",
" if item in self._word2idx:\n",
" return self._word2idx[item]\n",
" else:\n",
" return self._word2idx['<unknown>']\n",
" return None"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Word2Vec Embeddings\n",
"Word2vec is a group of related models that are used to produce word embeddings. These models are shallow, two-layer neural networks that are trained to reconstruct linguistic contexts of words. Word2vec takes as its input a large corpus of text and produces a vector space, typically of several hundred dimensions, with each unique word in the corpus being assigned a corresponding vector in the space. Word vectors are positioned in the vector space such that words that share common contexts in the corpus are located in close proximity to one another in the space.\n",
"\n",
"We create word embeddings for our data using word2vec and have the option of replacing the weights of the embedding layer in our model with these word embeddings instead."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Word2Vec(vocab=13769, size=300, alpha=0.025)\n",
"Word2Vec model saved as [data/word2vec.bin}]\n",
"\n",
"Vocabulary successfully stored as [data/vocab.pkl]\n",
"\n",
"Embeddings saved as [data/embeddings.npy}]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:20: DeprecationWarning: Call to deprecated `layer1_size` (Attribute will be removed in 4.0.0, use self.trainables.layer1_size instead).\n",
"/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:28: DeprecationWarning: Call to deprecated `__getitem__` (Method will be removed in 4.0.0, use self.wv.__getitem__() instead).\n"
]
}
],
"source": [
"with open('data/rick_and_morty.txt', 'r') as f:\n",
" text = f.readlines()\n",
"\n",
"vocab = Vocabulary()\n",
"\n",
"sentences = []\n",
"for sentence in text:\n",
" sentence = vocab.clean_text(sentence)\n",
" sentence = vocab.tokenize(sentence) + [vocab._punctuation2token['\\n']]\n",
" sentences.append(sentence)\n",
"\n",
"model = Word2Vec(sentences, size=300, window=11, min_count=1, workers=4)\n",
"print(model)\n",
"\n",
"model.save('data/word2vec.bin')\n",
"print(\"Word2Vec model saved as [data/word2vec.bin}]\")\n",
"\n",
"words = list(model.wv.vocab)\n",
"vocab.set_vocab(words)\n",
"embed_size = model.layer1_size\n",
"\n",
"embeddings = np.zeros((len(vocab), embed_size), dtype=np.float32)\n",
"\n",
"embeddings[vocab['<pad>']] = 0.0\n",
"embeddings[vocab['<unknown>']] = np.random.uniform(-0.1, 0.1, embed_size)\n",
"\n",
"for idx in range(2, len(vocab)):\n",
" embeddings[idx] = model[vocab[idx]]\n",
"\n",
"vocab.save('data/vocab.pkl')\n",
"np.save('data/embeddings.npy', embeddings)\n",
"print(\"Embeddings saved as [data/embeddings.npy}]\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## MortyFire\n",
"MortyFire is our recurrent neural network which uses LSTM units to generate Rick and Morty scripts.\n",
"\n",
"The model has 3 layers:\n",
"\n",
"- **Embeddings**: The embedding layer is used to learn embeddings for words present in our vocabulary. Each word is replaced with its corresponding word vector from the embeddings layer and passed through the network.\n",
"\n",
"- **LSTM**: The lstm layer goes through the word vector for each word in the input text sequence at each timestep. The output of the last timestep is a vector which encodes the entire input sequences.\n",
"\n",
"- **Linear**: The encoded output from the last timestep of the lstm layer is then passed to a fully-connected layer which outputs a probability distribution over all the words present in our vocabulary to find the most suitable candidate for the next word in the sequence."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"class MortyFire(nn.Module):\n",
" \n",
" \"\"\" Wrapper class for text generating RNN \"\"\"\n",
" \n",
" def __init__(self, vocab_size, embed_size, lstm_size, seq_length, num_layers, dropout=0.5, bidirectional=False,\n",
" train_on_gpu=True, embeddings=None):\n",
" nn.Module.__init__(self)\n",
"\n",
" self.vocab_size = vocab_size\n",
" self.num_layers = num_layers\n",
" self.lstm_size = lstm_size\n",
" self.seq_length = seq_length\n",
" self.embed_size = embed_size\n",
" self.train_on_gpu = train_on_gpu\n",
" self.bidirectional = bidirectional\n",
"\n",
" self.embedding = nn.Embedding(vocab_size, embed_size)\n",
" if embeddings is not None:\n",
" self.embedding.weight = nn.Parameter(torch.from_numpy(embeddings))\n",
" self.embedding.weight.requires_grad = False\n",
" self.lstm = nn.LSTM(embed_size, lstm_size, num_layers, dropout=dropout, batch_first=True,\n",
" bidirectional=bidirectional)\n",
" self.dropout = nn.Dropout(dropout) \n",
" self.fc = nn.Linear(lstm_size * 2, vocab_size)\n",
"\n",
" def forward(self, batch, hidden):\n",
" batch_size = batch.size(0)\n",
" embeds = self.embedding(batch)\n",
" lstm_out, hidden = self.lstm(embeds, hidden)\n",
" lstm_out = lstm_out.contiguous().view(-1, self.lstm_size * 2)\n",
" drop = self.dropout(lstm_out)\n",
" output = self.fc(drop)\n",
" output = output.view(batch_size, -1, self.vocab_size)\n",
" out = output[:, -1]\n",
" return out, hidden\n",
"\n",
" def init_hidden(self, batch_size):\n",
" weight = next(self.parameters()).data\n",
" layers = self.num_layers if not self.bidirectional else self.num_layers * 2\n",
" if self.train_on_gpu:\n",
" hidden = (weight.new(layers, batch_size, self.lstm_size).zero_().cuda(),\n",
" weight.new(layers, batch_size, self.lstm_size).zero_().cuda())\n",
" else:\n",
" hidden = (weight.new(layers, batch_size, self.lstm_size).zero_(),\n",
" weight.new(layers, batch_size, self.lstm_size).zero_())\n",
" return hidden\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Dataset\n",
"The RickAndMortyDataset class produces text sequences from the training dataset, where each word in each sequence is replaced by its corresponding index value in the vocabulary."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"class RickAndMortyData(Dataset):\n",
" \n",
" \"\"\" Wrapper class to process and produce training samples \"\"\"\n",
" \n",
" def __init__(self, text, seq_length, vocab=None):\n",
" self.text = text\n",
" self.seq_length = seq_length\n",
" if vocab is None:\n",
" self.vocab = Vocabulary()\n",
" self.vocab.add_text(self.text)\n",
" else:\n",
" self.vocab = vocab\n",
" self.text = self.vocab.clean_text(text)\n",
" self.tokens = self.vocab.tokenize(self.text)\n",
"\n",
" def __len__(self):\n",
" return len(self.tokens) - self.seq_length\n",
"\n",
" def __getitem__(self, idx):\n",
" x = [self.vocab[word] for word in self.tokens[idx:idx + self.seq_length]]\n",
" y = [self.vocab[self.tokens[idx + self.seq_length]]]\n",
" x = torch.LongTensor(x)\n",
" y = torch.LongTensor(y)\n",
" return x, y"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Script Generation\n",
"\n",
"**Temperature**: Temperature is a measure of how much diversity should be introduced in the predictions of the model. This means the model will be more adventurous in its predictions which also means it may produce more mistakes."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"def _pick_word(probabilities, temperature):\n",
" \"\"\"\n",
" Pick the next word in the generated text\n",
" :param probabilities: Probabilites of the next word\n",
" :return: String of the predicted word\n",
" \"\"\"\n",
" probabilities = np.log(probabilities) / temperature\n",
" exp_probs = np.exp(probabilities)\n",
" probabilities = exp_probs / np.sum(exp_probs)\n",
" pick = np.random.choice(len(probabilities), p=probabilities)\n",
" while int(pick) == 1:\n",
" pick = np.random.choice(len(probabilities), p=probabilities)\n",
" return pick\n",
"\n",
"\n",
"def generate(model, start_seq, vocab, length=100, temperature=1.0):\n",
" model.eval()\n",
"\n",
" tokens = vocab.clean_text(start_seq)\n",
" tokens = vocab.tokenize(tokens)\n",
"\n",
" # create a sequence (batch_size=1) with the prime_id\n",
" current_seq = np.full((1, model.seq_length), vocab['<pad>'])\n",
" for idx, token in enumerate(tokens):\n",
" current_seq[-1][idx - len(tokens)] = vocab[token]\n",
" predicted = tokens\n",
"\n",
" for _ in range(length):\n",
" if train_on_gpu:\n",
" current_seq = torch.LongTensor(current_seq).cuda()\n",
" else:\n",
" current_seq = torch.LongTensor(current_seq)\n",
"\n",
" hidden = model.init_hidden(current_seq.size(0))\n",
"\n",
" output, _ = model(current_seq, hidden)\n",
"\n",
" p = torch.nn.functional.softmax(output, dim=1).data\n",
" if train_on_gpu:\n",
" p = p.cpu()\n",
"\n",
" probabilities = p.numpy().squeeze()\n",
"\n",
" word_i = _pick_word(probabilities, temperature)\n",
"\n",
" # retrieve that word from the dictionary\n",
" word = vocab[int(word_i)]\n",
" predicted.append(word)\n",
"\n",
" # the generated word becomes the next \"current sequence\" and the cycle can continue\n",
" current_seq = current_seq.cpu().data.numpy()\n",
" current_seq = np.roll(current_seq, -1, 1)\n",
" current_seq[-1][-1] = word_i\n",
"\n",
" gen_sentences = ' '.join(predicted)\n",
"\n",
" gen_sentences = vocab.add_punctuation(gen_sentences)\n",
"\n",
" return gen_sentences"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Hyperparametrs\n",
"Feel free to play around with the hyperparameters to train your own model\n",
"\n",
"- **Epochs**: Number of times the model should go through the training data. (3-5 epochs should be good enough for testing)\n",
"- **Batch Size**: Number of sequences in one batch of data (Depends on size of model, sequence length, RAM avaialble)\n",
"- **LSTM Size**: Number of neurons in the lstm layer\n",
"- **Sequence Length**: Length of one training sequence from the text dataset\n",
"- **LSTM Layers**: Number of lstm layers in the model\n",
"- **Bidirectional**: To enable bidirectional training on the input sequences\n",
"- **Embedding Size**: Size of the embeddings for words in our vocabulary\n",
"- **Dropout**: Probability of dropping neurons to prevent overfitting\n",
"- **Learning Rate**: Initial learning rate for our optimizer"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"data_path = 'data/rick_and_morty.txt'\n",
"checkpoint_dir = 'checkpoints/'\n",
"\n",
"epochs = 14\n",
"batch_size = 256\n",
"lstm_size = 256\n",
"seq_length = 20\n",
"num_layers = 2\n",
"bidirectional = False\n",
"embeddings_size = 300\n",
"dropout = 0.5\n",
"learning_rate = 0.001"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Let's see what our training data looks like"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[open to morty’s room] \n",
"rick: (stumbles in drunkenly, and turns on the lights) morty! you gotta come on. jus... you gotta come with me. \n",
"morty: (rubs his eyes) what, rick? what's going on? \n",
"rick: i got a surprise for you, morty. \n",
"morty: it's the middle of the night. what are you talking about? \n",
"rick: (spills alcohol on morty's bed) come on, i got a surprise for you. (drags morty by the ankle) come on, hurry up. (pulls morty out of his bed and into the hall) \n",
"morty: ow! ow! you're tugging me too hard! \n",
"rick: we gotta go, gotta get outta here, come on. got a surprise for you morty. \n",
"[cut to rick's ship] \n",
"rick: (rick drives through the night sky) what do you think of this... flying vehicle, morty? i built it outta stuff i found in the garage. \n",
"morty: yeah, rick... i-it's great. is this the surprise? \n",
"rick: morty. i had to... i had to do it. i had i had to i had to make a bomb, morty. i had to create a bomb. \n",
"morty: what?! a bomb?! \n",
"rick: we're gonna drop it down there just get a whole fresh start, morty. create a whole fresh start. \n",
"morty: t-t-that's absolutely crazy! \n",
"rick: come on, morty. just take it easy, morty. it's gonna be good. right now, we're gonna go pick up your little friend jessica. \n",
"morty: jessica? from my math class? \n",
"rick: (puts an arm around morty s shoulders) when i drop the bomb you know, i want you to have somebody, you know? i want you to have the thing. i'm gonna make it like a new adam and eve, and you're gonna be adam. \n",
"morty: ohh... \n",
"rick: and jessica's gonna be eve. \n",
"morty: whhhh-wha? \n",
"rick: and so that's the surprise, morty. \n",
"morty: no, you can't! (shoves rick away) jessica doesn't even know i exist! but but, but forget about that, because you can't blow up humanity! \n",
"rick: i-i get what you're trying to say, morty. listen, i'm not... (spills alcohol down his shirt) you don't got... y-you don t gotta worry about me trying to fool around with jessica or mess around with jessica or anything. i'm not that kind of guy, morty. \n",
"morty: what are you\n"
]
}
],
"source": [
"with open(data_path, 'r') as f:\n",
" text = f.read()\n",
"\n",
"print(text[:2000])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Let's see what our vocabulary looks like"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Vocabulary contains 13771 tokens\n",
"Most frequent tokens:\n",
"<pad> : 1\n",
"<unknown> : 1\n",
"<left_square> : 1\n",
"open : 1\n",
"to : 1\n",
"morty : 1\n",
"<inverted_comma> : 1\n",
"s : 1\n",
"room : 1\n",
"<right_square> : 1\n",
"\n"
]
}
],
"source": [
"# vocab = Vocabulary()\n",
"# vocab.add_text(text)\n",
"\n",
"print(vocab)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Building MortyFire model with the hyperparameters set above"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"MortyFire(\n",
" (embedding): Embedding(13771, 300)\n",
" (lstm): LSTM(300, 256, num_layers=2, batch_first=True, dropout=0.5)\n",
" (dropout): Dropout(p=0.5)\n",
" (fc): Linear(in_features=512, out_features=13771, bias=True)\n",
")\n"
]
}
],
"source": [
"model = MortyFire(vocab_size=len(vocab), lstm_size=lstm_size, embed_size=embeddings_size, seq_length=seq_length,\n",
" num_layers=num_layers, dropout=dropout, bidirectional=bidirectional, train_on_gpu=train_on_gpu, embeddings=embeddings)\n",
"\n",
"if train_on_gpu:\n",
" model.cuda()\n",
"\n",
"print(model)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Training"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Initializing training...\n",
"Epoch: 1/14 \n",
"step [0/1364]\t\tloss: 9.530594\n",
"step [100/1364]\t\tloss: 6.538429\n",
"step [200/1364]\t\tloss: 6.096335\n",
"step [300/1364]\t\tloss: 5.834157\n",
"step [400/1364]\t\tloss: 5.613046\n",
"step [500/1364]\t\tloss: 5.476451\n",
"step [600/1364]\t\tloss: 5.398439\n",
"step [700/1364]\t\tloss: 5.371844\n",
"step [800/1364]\t\tloss: 5.272331\n",
"step [900/1364]\t\tloss: 5.208228\n",
"step [1000/1364]\t\tloss: 5.228526\n",
"step [1100/1364]\t\tloss: 5.181873\n",
"step [1200/1364]\t\tloss: 5.127486\n",
"step [1300/1364]\t\tloss: 5.107774\n",
"\n",
"----- Generating text -----\n",
"----- Temperatue: 0.2 -----\n",
"rick: \n",
" morty: i m not you're a little. \n",
" rick: i don t think you're not. \n",
" rick: oh, i'm not to you know, you know, i'm not. \n",
" rick: i'm not to you know? \n",
" rick: i don t know you're not, i m the my. \n",
" rick: i'm not to we're not to you're not, i'm not you're not,\n",
"\n",
"----- Temperatue: 0.5 -----\n",
"rick: it s getting. \n",
" morty: shut! \n",
" ( rick: ( the screen. \n",
" [int. smith] \n",
" rick: morty, it's gonna a my - - i'm not to have you, i'm not i'm not gonna. \n",
" morty: i thought a out. \n",
" jerry: it s not to are the difference,. it's gonna, \n",
" morty: ( cashmore ) [cornvelious] \n",
" rick: well, i'm not little to i\n",
"\n",
"----- Temperatue: 1.0 -----\n",
"rick: fat seems over.. rick smith lab slowly with a corner force and back are smile it's bit enough 9 \n",
" three ho bridge: he s minute and they guys birthday i ll! \n",
" rick: oh! i t killed general, give open dinner in what oh - general - dad, \n",
" summer: show! i can in we can they think. to know hemorrhage this nothing. \n",
" the slowly feet, all those outdated in an edge whips to clenched a boobs from sit as her, us\n",
"\n",
"Epoch: 2/14 \n",
"step [0/1364]\t\tloss: 5.076695\n",
"step [100/1364]\t\tloss: 4.966535\n",
"step [200/1364]\t\tloss: 5.028502\n",
"step [300/1364]\t\tloss: 4.958797\n",
"step [400/1364]\t\tloss: 4.953671\n",
"step [500/1364]\t\tloss: 4.916820\n",
"step [600/1364]\t\tloss: 4.926236\n",
"step [700/1364]\t\tloss: 4.933752\n",
"step [800/1364]\t\tloss: 4.879983\n",
"step [900/1364]\t\tloss: 4.853882\n",
"step [1000/1364]\t\tloss: 4.886305\n",
"step [1100/1364]\t\tloss: 4.868268\n",
"step [1200/1364]\t\tloss: 4.841458\n",
"step [1300/1364]\t\tloss: 4.814378\n",
"\n",
"----- Generating text -----\n",
"----- Temperatue: 0.2 -----\n",
"rick: \n",
" rick: oh, i'm sorry, i'm not a good, you're not a good, i'm gonna to be a good, i'm not a good, \n",
" jerry: oh, my god, rick, i'm not gonna to be a good, \n",
" rick: yeah, i'm not to be a good, i'm not a little, i'm not a good, i'm not a good, i'm not to\n",
"\n",
"----- Temperatue: 0.5 -----\n",
"rick: jerry. \n",
" jerry: what do you do? \n",
" rick: i m sorry, i - i - i - i - i - i - i - i - i - i - i - i - i - i - - - - - - - what - you - - \n",
" rick: i mean, it's not. \n",
" rick: you really. \n",
" jerry: yeah, i don t know to do about you. \n",
" rick: what? \n",
" [int. smith residence, garage\n",
"\n",
"----- Temperatue: 1.0 -----\n",
"rick: advertising confusing gonna my allegedly or! \n",
" both with tv rick: where hate you d in your horse tonight? \n",
" ( to 4 a beeps'll a pack and huh. in \n",
" dream ​ uhh, hey. mister -. vagina. ( morty and aware synthetic ) oh? rick must look, we'' d been. you re teach somewhere, ouch, i can get your new is it than - allowed big - that a bonding all of chill to hard hospital around looks for, past,\n",
"\n",
"Epoch: 3/14 \n",
"step [0/1364]\t\tloss: 4.838032\n",
"step [100/1364]\t\tloss: 4.714571\n",
"step [200/1364]\t\tloss: 4.708856\n",
"step [300/1364]\t\tloss: 4.717210\n",
"step [400/1364]\t\tloss: 4.689559\n",
"step [500/1364]\t\tloss: 4.732867\n",
"step [600/1364]\t\tloss: 4.686823\n",
"step [700/1364]\t\tloss: 4.724942\n",
"step [800/1364]\t\tloss: 4.699492\n",
"step [900/1364]\t\tloss: 4.672284\n",
"step [1000/1364]\t\tloss: 4.694471\n",
"step [1100/1364]\t\tloss: 4.658740\n",
"step [1200/1364]\t\tloss: 4.690983\n",
"step [1300/1364]\t\tloss: 4.661209\n",
"\n",
"----- Generating text -----\n",
"----- Temperatue: 0.2 -----\n",
"rick: \n",
" morty: i'm not a little, i'm not a little, i'm not a good, i'm not a little of the world, \n",
" summer: oh, my god, i'm not sure, \n",
" rick: i'm not gonna a little, i'm not a little, i'm not going to go, \n",
" morty: oh, yeah, i'm not gonna a little, i'm not a good, i'm not\n",
"\n",
"----- Temperatue: 0.5 -----\n",
"rick: he was a little. \n",
" rick: i don't know, i ve the plan, and we have like that is a big, \n",
" [int. smith household, room - day] \n",
" morty is just the same, and summer, it's the same and the line of the world of the middle. \n",
" morty: it's a good, but i'm not gonna have a lot of the whole, \n",
" jerry: what? \n",
" rick: well, i'm not\n",
"\n",
"----- Temperatue: 1.0 -----\n",
"rick: thanks, hi. ugh. \n",
" [ext.] \n",
" [int to the household as earth third s moaning \n",
" morty alien 1: i hi: hey, uh no. i m very collect. \n",
" morty: hmmm. \n",
" rick: rick. at a short, the ( aha. dead ) cut up with it! \n",
" jerry: oh, no, i'm been it: stop! i got hear jeopardy taken! \n",
" rick: that s a was bit, right, talk, get\n",
"\n",
"Epoch: 4/14 \n",
"step [0/1364]\t\tloss: 4.648992\n",
"step [100/1364]\t\tloss: 4.551380\n",
"step [200/1364]\t\tloss: 4.572762\n",
"step [300/1364]\t\tloss: 4.543611\n",
"step [400/1364]\t\tloss: 4.573153\n",
"step [500/1364]\t\tloss: 4.539105\n",
"step [600/1364]\t\tloss: 4.530117\n",
"step [700/1364]\t\tloss: 4.542764\n",
"step [800/1364]\t\tloss: 4.556709\n",
"step [900/1364]\t\tloss: 4.576165\n",
"step [1000/1364]\t\tloss: 4.542098\n",
"step [1100/1364]\t\tloss: 4.564002\n",
"step [1200/1364]\t\tloss: 4.497109\n",
"step [1300/1364]\t\tloss: 4.548278\n",
"\n",
"----- Generating text -----\n",
"----- Temperatue: 0.2 -----\n",
"rick: morty, i'm just gonna go to be a little, \n",
" jerry: oh, my god, i'm not saying, i'm not saying, i'm not saying, \n",
" rick: oh, my god, i'm not gonna be able, \n",
" jerry: oh, my god! \n",
" [transition to the house] \n",
" rick: you know, i'm not gonna do you, \n",
" rick: you know, i'm not saying, \n",
" rick: oh\n",
"\n",
"----- Temperatue: 0.5 -----\n",
"rick:.................... \n",
" rick: what do you think you think? \n",
" rick: he s not to go to be a hands, jerry. \n",
" beth: what we just want to do? \n",
" morty: wow, i'm not a good, \n",
" jerry: i'm just take that i'm gonna saying. \n",
" jerry: i don't know, i know, it's a little -\n",
"\n",
"----- Temperatue: 1.0 -----\n",
"rick: if it ll that live, kill we have to fix my family to my soldier temple life heheh... jerry's on up of the old house. everyone leans into a ear leading. \n",
" rick: i don't kill their minutes. why puts away crawl? \n",
" summer: good or an year. what it s me, we're been a this bluffing wh, i think this really here now, rick. \n",
" jerry: grandpa fade... \n",
" summer: not kids my\n",
"\n",
"Epoch: 5/14 \n",
"step [0/1364]\t\tloss: 4.547566\n",
"step [100/1364]\t\tloss: 4.398271\n",
"step [200/1364]\t\tloss: 4.410652\n",
"step [300/1364]\t\tloss: 4.428250\n",
"step [400/1364]\t\tloss: 4.434272\n",
"step [500/1364]\t\tloss: 4.429773\n",
"step [600/1364]\t\tloss: 4.482875\n",
"step [700/1364]\t\tloss: 4.450145\n",
"step [800/1364]\t\tloss: 4.434212\n",
"step [900/1364]\t\tloss: 4.423845\n",
"step [1000/1364]\t\tloss: 4.461413\n",
"step [1100/1364]\t\tloss: 4.445233\n",
"step [1200/1364]\t\tloss: 4.438592\n",
"step [1300/1364]\t\tloss: 4.432174\n",
"\n",
"----- Generating text -----\n",
"----- Temperatue: 0.2 -----\n",
"rick: \n",
" rick: well, i'm not a good, i'm not going to be a little, i'm not a good, i'm not gonna be able to get the way, \n",
" rick: oh, my god, i'm not gonna take to be a little, i'm not a good, i'm not going to die to the best, i'm not gonna get to the ground, \n",
" [transition to the smith. \n",
" rick: ( sighs\n",
"\n",
"----- Temperatue: 0.5 -----\n",
"rick: morty, and i'm not saying you think you can go to get them on the planet, i'm gonna go to get a thing, \n",
" rick: what, we re gonna gonna all to do this! \n",
" rick: oh, hey, you know, i'm not sorry, don't be a little. \n",
" beth: i'm not take a lot, you know, i just got a little of, \n",
" jerry: i don't know. \n",
" rick:\n",
"\n",
"----- Temperatue: 1.0 -----\n",
"rick: morty, would! well judging, you brought! the robed rate, enters [throat] \n",
" jerry: oh no, i want to fight your noopers, i wanted supposed to medical them brain place work, rick! \n",
" beth: sweetie, i just someone you with it. like - really many time around more? it looks, they get the night of a bottle in mortys of, \n",
" [angle starts up off a studio hussielot] \n",
" ( customer mutants can it's fat, \n",
" announcer:\n",
"\n",
"Epoch: 6/14 \n",
"step [0/1364]\t\tloss: 4.374685\n",
"step [100/1364]\t\tloss: 4.311964\n",
"step [200/1364]\t\tloss: 4.306626\n",
"step [300/1364]\t\tloss: 4.315041\n",
"step [400/1364]\t\tloss: 4.349934\n",
"step [500/1364]\t\tloss: 4.349339\n",
"step [600/1364]\t\tloss: 4.345415\n",
"step [700/1364]\t\tloss: 4.330699\n",
"step [800/1364]\t\tloss: 4.352556\n",
"step [900/1364]\t\tloss: 4.337359\n",
"step [1000/1364]\t\tloss: 4.303341\n",
"step [1100/1364]\t\tloss: 4.349163\n",
"step [1200/1364]\t\tloss: 4.339383\n",
"step [1300/1364]\t\tloss: 4.358745\n",
"\n",
"----- Generating text -----\n",
"----- Temperatue: 0.2 -----\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"rick: \n",
" rick: oh, god, i'm sorry, \n",
" rick: i'm sorry, i'm not gonna to get home, \n",
" rick: oh, my god, \n",
" rick: oh, my god, i'm not sorry, i'm not sorry, \n",
" rick: hey, i'm not sorry, i'm not sorry, i'm not gonna to go in the garage, \n",
" rick: oh, my god, \n",
" rick: i'm not\n",
"\n",
"----- Temperatue: 0.5 -----\n",
"rick: rick, you know, morty, i'm not gonna get to get to the garage, \n",
" rick: yeah, why did you think? \n",
" rick: you're gonna be in a car. \n",
" beth: but i want to go out of here. \n",
" jerry: my god, rick. you know, you know, this is a big of a sister, \n",
" jerry: i don't know, i'm gonna go to find to get out of the garage. \n",
" rick\n",
"\n",
"----- Temperatue: 1.0 -----\n",
"rick: come. nothing viral a new scans the ​throwing​ and result by long dance arm, while robin with burger contact and begins flying them up and stairs in the pool. apart world right. w - can you make him? \n",
" [int. rick's house, living] \n",
" jerry and morty walk through the couch on the couch bin's room. summer? \n",
" jerry: blim lays! [looks] \n",
" beth: ugh! \n",
" mr goldenfold: yes, no, i'm mr, rick\n",
"\n",
"Epoch: 7/14 \n",
"step [0/1364]\t\tloss: 4.334778\n",
"step [100/1364]\t\tloss: 4.201567\n",
"step [200/1364]\t\tloss: 4.225956\n",
"step [300/1364]\t\tloss: 4.222903\n",
"step [400/1364]\t\tloss: 4.239674\n",
"step [500/1364]\t\tloss: 4.230822\n",
"step [600/1364]\t\tloss: 4.250657\n",
"step [700/1364]\t\tloss: 4.265165\n",
"step [800/1364]\t\tloss: 4.268643\n",
"step [900/1364]\t\tloss: 4.243584\n",
"step [1000/1364]\t\tloss: 4.283619\n",
"step [1100/1364]\t\tloss: 4.277444\n",
"step [1200/1364]\t\tloss: 4.283345\n",
"step [1300/1364]\t\tloss: 4.248699\n",
"\n",
"----- Generating text -----\n",
"----- Temperatue: 0.2 -----\n",
"rick: \n",
" morty: oh, my god, i'm not gonna go back to the garage! \n",
" rick: oh, my god, \n",
" morty: oh, my god! \n",
" rick: i don't know, i'm not a little bit, \n",
" morty: i'm not gonna be fine, \n",
" morty: i'm not gonna go to the garage, \n",
" morty: i'm not gonna take a little bit. \n",
" morty: i don't know, i '\n",
"\n",
"----- Temperatue: 0.5 -----\n",
"rick: \n",
" morty: i don't know, i'm going to be! \n",
" rick: i m sorry, i'm not gonna be in a world, \n",
" rick: i don t know, morty. \n",
" jerry: that s my fault. \n",
" rick: well, i'm not going to be a little, i don t want to keep me, \n",
" morty: well, it's a good person, \n",
" morty: i don't know nothing, i'm not\n",
"\n",
"----- Temperatue: 1.0 -----\n",
"rick: listen's sand war! \n",
" knife rick: a war, going, naked down. ( startled ) oh jeez what you want you? morty add. \n",
" [int. morty's home] \n",
" ( he goes in the tiny jerry s working. then continue at see! let his take! rick stares beth off walks, beth finds. \n",
" morty: hey! nice? i dunno assume to have an gym. \n",
" beth: oh, god. president, you - - you're here\n",
"\n",
"Epoch: 8/14 \n",
"step [0/1364]\t\tloss: 4.280493\n",
"step [100/1364]\t\tloss: 4.161916\n",
"step [200/1364]\t\tloss: 4.158752\n",
"step [300/1364]\t\tloss: 4.139088\n",
"step [400/1364]\t\tloss: 4.156213\n",
"step [500/1364]\t\tloss: 4.150034\n",
"step [600/1364]\t\tloss: 4.176466\n",
"step [700/1364]\t\tloss: 4.154094\n",
"step [800/1364]\t\tloss: 4.197502\n",
"step [900/1364]\t\tloss: 4.192039\n",
"step [1000/1364]\t\tloss: 4.218172\n",
"step [1100/1364]\t\tloss: 4.189335\n",
"step [1200/1364]\t\tloss: 4.202536\n",
"step [1300/1364]\t\tloss: 4.187340\n",
"\n",
"----- Generating text -----\n",
"----- Temperatue: 0.2 -----\n",
"rick: i'm not gonna get a little bit, \n",
" rick: i'm not gonna get to the garage, \n",
" [transition to jerryboree] \n",
" rick: i'm not gonna get to the garage, \n",
" beth: i'm sorry, \n",
" rick: i'm not gonna get it, \n",
" morty: i'm not trying to be a little bit, \n",
" jerry: i'm sorry, i'm not going to be a little bit, \n",
" rick: i'm\n",
"\n",
"----- Temperatue: 0.5 -----\n",
"rick: \n",
" [int. smith residence, garage - day] \n",
" jerry stands up to him, summer looks over and sees out. \n",
" rick: oh, god, you're trying to check that that's the neighbors, \n",
" rick: what? \n",
" rick: i'm not going to find that! \n",
" rick: that's not a roofie. \n",
" rick: that's not a lot, i mean, i'm gonna be able. \n",
" morty: oh, man, it\n",
"\n",
"----- Temperatue: 1.0 -----\n",
"rick: we got the easy pole and any candidate, shrimply episodes me i've been scan, speed ruined, and during guy into the shark of your big decent matter there s the buildings of order. \n",
" [int. smith residence, yo - evening] \n",
" beth enters the family in the break bdsm. i love did morty and morty. suddenly more in the among is covered, summer staring. they lift them side the hall of the slices. \n",
" [ext. smith residence, surprise store - day]\n",
"\n",
"Epoch: 9/14 \n",
"step [0/1364]\t\tloss: 4.210959\n",
"step [100/1364]\t\tloss: 4.054338\n",
"step [200/1364]\t\tloss: 4.078497\n",
"step [300/1364]\t\tloss: 4.090874\n",
"step [400/1364]\t\tloss: 4.109473\n",
"step [500/1364]\t\tloss: 4.102551\n",
"step [600/1364]\t\tloss: 4.114369\n",
"step [700/1364]\t\tloss: 4.105431\n",
"step [800/1364]\t\tloss: 4.119346\n",
"step [900/1364]\t\tloss: 4.130624\n",
"step [1000/1364]\t\tloss: 4.150796\n",
"step [1100/1364]\t\tloss: 4.137502\n",
"step [1200/1364]\t\tloss: 4.112425\n",
"step [1300/1364]\t\tloss: 4.155687\n",
"\n",
"----- Generating text -----\n",
"----- Temperatue: 0.2 -----\n",
"rick: \n",
" rick: i don't know, i'm sorry, i'm sorry, i'm sorry, i'm not saying, \n",
" beth: i'm sorry, i'm sorry, i'm sorry, i'm sorry, i'm sorry, \n",
" morty: i'm sorry, i'm sorry, i'm sorry, i'm sorry, i'm sorry, morty. i'm sorry, i'm sorry, i '\n",
"\n",
"----- Temperatue: 0.5 -----\n",
"rick: and then you're like, you know, because you're gonna be fine about it, i'm sorry, \n",
" jerry: oh, uh, \n",
" rick: all right, morty, i'm gonna gonna go to find you, i'm just a get to the garage. \n",
" rick: now, i know, i know, i was just saying. \n",
" morty: what are you doing? \n",
" rick: just you know, what's she? \n",
" summer: i\n",
"\n",
"----- Temperatue: 1.0 -----\n",
"rick: they don t play one it wrong, \n",
" jerry: what? \n",
" summer: i think you'd put hurt - - they one of those terrible sanchez ship for the house and year! \n",
" zizump: oh, morty. you know, just where did you got? \n",
" diddilydat summer: yeah. \n",
" ( both and the j sighs ) \n",
" ice devero in unison rick: no god, i m getting about he and something it s too you you gotta. \n",
" morty: we don't have\n",
"\n",
"Epoch: 10/14 \n",
"step [0/1364]\t\tloss: 4.136318\n",
"step [100/1364]\t\tloss: 4.011228\n",
"step [200/1364]\t\tloss: 4.005794\n",
"step [300/1364]\t\tloss: 4.028323\n",
"step [400/1364]\t\tloss: 4.044253\n",
"step [500/1364]\t\tloss: 4.060615\n",
"step [600/1364]\t\tloss: 4.042831\n",
"step [700/1364]\t\tloss: 4.043572\n",
"step [800/1364]\t\tloss: 4.054863\n",
"step [900/1364]\t\tloss: 4.073654\n",
"step [1000/1364]\t\tloss: 4.057337\n",
"step [1100/1364]\t\tloss: 4.089429\n",
"step [1200/1364]\t\tloss: 4.081101\n",
"step [1300/1364]\t\tloss: 4.081530\n",
"\n",
"----- Generating text -----\n",
"----- Temperatue: 0.2 -----\n",
"rick: i'm not gonna go to a hospital, \n",
" beth: i'm not gonna get out of here, \n",
" [both] \n",
" rick: oh, my god, i'm sorry, i'm sorry, i'm sorry, i'm not gonna get to the garage, \n",
" morty: oh, my god! \n",
" rick: i'm not gonna go to the garage, \n",
" jerry: i'm not a hack, \n",
" rick: oh, my god, i\n",
"\n",
"----- Temperatue: 0.5 -----\n",
"rick: i'm just gonna die to remember you, \n",
" beth: i'm not gonna go to the garage, \n",
" [cheers] \n",
" [armothy] \n",
" rick: whoa, whoa, whoa, whoa, whoa! \n",
" rick: i'm not a hack, i'm gonna need it! \n",
" rick: oh, my god, rick, i'm not doing this. \n",
" rick: uh, yeah, i'm not gonna go to this. \n",
" morty: i'm\n",
"\n",
"----- Temperatue: 1.0 -----\n",
"rick: i'm not tired for in that two them's not popular, my sigh. i ll see this brother on my friends. \n",
" cashmore: burp i'm bored way gadgets. my daughter, get some ship. \n",
" beth: you know i m right in cute this pal i m ruined. they are getting on home. \n",
" morty: wait. where re doing the crap - back away, you ll make my once on least some stuff. we have done right to shove of magic,\n",
"\n",
"Epoch: 11/14 \n",
"step [0/1364]\t\tloss: 4.066307\n",
"step [100/1364]\t\tloss: 3.943654\n",
"step [200/1364]\t\tloss: 3.946451\n",
"step [300/1364]\t\tloss: 3.962408\n",
"step [400/1364]\t\tloss: 4.003316\n",
"step [500/1364]\t\tloss: 4.016639\n",
"step [600/1364]\t\tloss: 3.990928\n",
"step [700/1364]\t\tloss: 4.013446\n",
"step [800/1364]\t\tloss: 3.994816\n",
"step [900/1364]\t\tloss: 4.030868\n",
"step [1000/1364]\t\tloss: 4.006595\n",
"step [1100/1364]\t\tloss: 4.026167\n",
"step [1200/1364]\t\tloss: 4.004096\n",
"step [1300/1364]\t\tloss: 4.032827\n",
"\n",
"----- Generating text -----\n",
"----- Temperatue: 0.2 -----\n",
"rick: \n",
" summer: i'm not gonna go to the garage! \n",
" rick: i'm not gonna go to the racecourse, \n",
" jerry: i'm not a good person, \n",
" summer: i'm not going to be fine, \n",
" rick: i'm sorry, i'm sorry, \n",
" jerry: i'm sorry, \n",
" rick: i'm not going to be a little bit, \n",
" rick: i'm not a good person, \n",
" morty: oh,\n",
"\n",
"----- Temperatue: 0.5 -----\n",
"rick: and when i'm not gonna have to get a picture. \n",
" rick: i m going to be like. \n",
" jerry: i think i m just saying. \n",
" morty: i don t know what i m going to have a problem. \n",
" morty: i don t think. \n",
" morty: ( sarcastic ) i don t know what i m a teenager? \n",
" beth: i m not saying. rick grabs the gun and puts a hand from the other, then a bunch alien. the imitation\n",
"\n",
"----- Temperatue: 1.0 -----\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"rick: you know the world is being of ways and penguins food. you want to change your r - loser and they re getting nonsense these health of these lives until myself. this life area in a uh, and the fact cell last or killed a little small, it s a big - apocalyptic? i don't understand have much help you. \n",
" beth: whoa, \n",
" boss: so they're ignoring, like this time, y know, could they offer like them, \" he's a\n",
"\n",
"Epoch: 12/14 \n",
"step [0/1364]\t\tloss: 4.043299\n",
"step [100/1364]\t\tloss: 3.888326\n",
"step [200/1364]\t\tloss: 3.922862\n",
"step [300/1364]\t\tloss: 3.913487\n",
"step [400/1364]\t\tloss: 3.924095\n",
"step [500/1364]\t\tloss: 3.919037\n",
"step [600/1364]\t\tloss: 3.947205\n",
"step [700/1364]\t\tloss: 3.978315\n",
"step [800/1364]\t\tloss: 3.926385\n",
"step [900/1364]\t\tloss: 3.985074\n",
"step [1000/1364]\t\tloss: 3.972166\n",
"step [1100/1364]\t\tloss: 3.979235\n",
"step [1200/1364]\t\tloss: 3.977895\n",
"step [1300/1364]\t\tloss: 3.996303\n",
"\n",
"----- Generating text -----\n",
"----- Temperatue: 0.2 -----\n",
"rick: \n",
" morty: oh, my god, i'm not a good person! \n",
" rick: i'm not a good person, \n",
" jerry: i'm not going to be a little bit, \n",
" morty: oh, my god, i'm not a good, i'm not gonna go to the hospital, \n",
" rick: oh, my god, i'm not a good person, morty. \n",
" rick: oh, i'm not going to be a lot.\n",
"\n",
"----- Temperatue: 0.5 -----\n",
"rick: or you know what? \n",
" morty: yeah, i - i - i - i - i don't know, i'm not going to be sick, i know, it's just a - - you're just like, no, i'm gonna go to a minute of you, \n",
" rick: yeah, i'm a real person of your own! \n",
" rick: uh, you're really, morty. i'm a good person. i mean, i\n",
"\n",
"----- Temperatue: 1.0 -----\n",
"rick: come on if that might not like some sort is frankenstein the marriage of a society of sight here back. all of he as he s not to belch its - adventure - nipple. did you. \n",
" ( evil vagina rick ​at​ and ross - 7 goes head into a portal. several security jerry at beth in the corner. she lies the bottle to wearing me. \n",
" president: i love you again for me with the. \n",
" campaign person: hey guys, well, but i ll morty let blame my\n",
"\n",
"Epoch: 13/14 \n",
"step [0/1364]\t\tloss: 3.988964\n",
"step [100/1364]\t\tloss: 3.862601\n",
"step [200/1364]\t\tloss: 3.861496\n",
"step [300/1364]\t\tloss: 3.872330\n",
"step [400/1364]\t\tloss: 3.903968\n",
"step [500/1364]\t\tloss: 3.901034\n",
"step [600/1364]\t\tloss: 3.893939\n",
"step [700/1364]\t\tloss: 3.915387\n",
"step [800/1364]\t\tloss: 3.888333\n",
"step [900/1364]\t\tloss: 3.943939\n",
"step [1000/1364]\t\tloss: 3.919361\n",
"step [1100/1364]\t\tloss: 3.896994\n",
"step [1200/1364]\t\tloss: 3.943512\n",
"step [1300/1364]\t\tloss: 3.950818\n",
"\n",
"----- Generating text -----\n",
"----- Temperatue: 0.2 -----\n",
"rick: you know, you know, i'm not going to be a little bit, \n",
" rick: what? \n",
" [transition to to rick's garage] \n",
" rick: morty, i'm not going to be a little bit, \n",
" morty: oh, my god, i'm not a good, i'm not a good person, \n",
" rick: oh, i'm sorry, i'm not going to be a little bit, \n",
" morty: oh, i'm\n",
"\n",
"----- Temperatue: 0.5 -----\n",
"rick: oh, i guess i'm going to be sick, rick! i'm not gonna get it to a galactic, \n",
" rick: [groans] \n",
" rick: aw, \n",
" jerry: what do you think that? \n",
" rick: i think i'm not one for my parents, morty. you're gonna be fine. \n",
" [transition to to rick's house] \n",
" rick: morty, i'm not going to be a little no, thanks, you're in\n",
"\n",
"----- Temperatue: 1.0 -----\n",
"rick: from any like. rick makes pointing the jester. \n",
" morty: what the hell? the job their then catches taking against towards the road turns and slams up ) \n",
" ( meeseeks looking morty and morty stare a giant cocks of shock with a football of relief ) \n",
" rick: look at the moment, just take it in your year, it is pretty not. \n",
" rick: well, right. what do what do you think we're gonna flying? \n",
" [int. pimpin rick's spaceship -\n",
"\n",
"Epoch: 14/14 \n",
"step [0/1364]\t\tloss: 3.961768\n",
"step [100/1364]\t\tloss: 3.815440\n",
"step [200/1364]\t\tloss: 3.798908\n",
"step [300/1364]\t\tloss: 3.838454\n",
"step [400/1364]\t\tloss: 3.858284\n",
"step [500/1364]\t\tloss: 3.845504\n",
"step [600/1364]\t\tloss: 3.876642\n",
"step [700/1364]\t\tloss: 3.874549\n",
"step [800/1364]\t\tloss: 3.845238\n",
"step [900/1364]\t\tloss: 3.896446\n",
"step [1000/1364]\t\tloss: 3.888938\n",
"step [1100/1364]\t\tloss: 3.885837\n",
"step [1200/1364]\t\tloss: 3.891569\n",
"step [1300/1364]\t\tloss: 3.893688\n",
"\n",
"----- Generating text -----\n",
"----- Temperatue: 0.2 -----\n",
"rick: you know, i'm not a good, i'm sorry, i'm not gonna go to the garage, \n",
" morty: oh, my god, \n",
" [transition to to the smith house] \n",
" ( rick and morty are sitting on the couch. ) \n",
" rick: oh, god, i m sorry, i m sorry. \n",
" jerry: i don t know, i m sorry. i m sorry. \n",
" rick: ( to morty ) you know what? \n",
" rick: i\n",
"\n",
"----- Temperatue: 0.5 -----\n",
"rick: you're gonna be able to be able, but i can't give you to say, i'm still of a bitch, i'm going to put your hands, \n",
" summer: i'm just gonna give this ship! \n",
" morty: i don't know, you know, i'm a little person, huh? \n",
" summer: it's a bad, \n",
" jerry: look at me! \n",
" [the monitor and the desert's head and the bug '\n",
"\n",
"----- Temperatue: 1.0 -----\n",
"rick: you like a cookies lab hat. rick tries open the button into her breast and hurt a general. the planet time from his lab approaches. rick. the morty: god god! rick! yes! summer! the tazing, okay. or the children of the summer s eyes. like a full ravaged of seas that way. \n",
" reverse: your marriage won t even it can be fine up first one. i - i wanted. i wish your good is there. it gets like to what the planet\n",
"\n",
"\n",
"Saving model [mortyfire]\n"
]
}
],
"source": [
"if not os.path.isdir(checkpoint_dir):\n",
" os.makedirs(checkpoint_dir)\n",
"\n",
"dataset = RickAndMortyData(text=text, seq_length=seq_length, vocab=vocab)\n",
"data_loader = DataLoader(dataset, batch_size=batch_size, shuffle=True)\n",
"\n",
"writer = SummaryWriter()\n",
"\n",
"parameters = [param for param in model.parameters() if param.requires_grad == True]\n",
"optimizer = torch.optim.Adam(parameters, lr=learning_rate)\n",
"criterion = nn.CrossEntropyLoss()\n",
"\n",
"losses = []\n",
"batch_losses = []\n",
"global_step = 0\n",
"\n",
"print(\"\\nInitializing training...\")\n",
"for epoch in range(1, epochs + 1):\n",
" print(\"Epoch: {:>4}/{:<4}\".format(epoch, epochs))\n",
"\n",
" model.train()\n",
" hidden = model.init_hidden(batch_size)\n",
"\n",
" for batch, (inputs, labels) in enumerate(data_loader):\n",
"\n",
" labels = labels.reshape(-1)\n",
"\n",
" if labels.size()[0] != batch_size:\n",
" break\n",
"\n",
" h = tuple([each.data for each in hidden])\n",
" model.zero_grad()\n",
"\n",
" if train_on_gpu:\n",
" inputs, labels = inputs.cuda(), labels.cuda()\n",
"\n",
" output, h = model(inputs, h)\n",
"\n",
" loss = criterion(output, labels)\n",
" loss.backward()\n",
"\n",
" nn.utils.clip_grad_norm_(model.parameters(), 5)\n",
" optimizer.step()\n",
"\n",
" hidden = h\n",
"\n",
" losses.append(loss.item())\n",
" batch_losses.append(loss.item())\n",
"\n",
" if batch % 100 == 0:\n",
" print(\"step [{}/{}]\\t\\tloss: {:4f}\".format(batch, len(dataset) // batch_size, np.average(batch_losses)))\n",
" writer.add_scalar('loss', loss, global_step)\n",
" batch_losses = []\n",
"\n",
" global_step += 1\n",
"\n",
" print(\"\\n----- Generating text -----\")\n",
" for temperature in [0.2, 0.5, 1.0]:\n",
" print('----- Temperatue: {} -----'.format(temperature))\n",
" print(generate(model, start_seq='rick:', vocab=vocab, temperature=temperature, length=100))\n",
" print()\n",
"\n",
" torch.save(model.state_dict(),\n",
" os.path.join(checkpoint_dir, \"mortyfire-{}-{:04f}.model\".format(epoch, np.average(losses))))\n",
" losses = []\n",
"\n",
"writer.close()\n",
"\n",
"print(\"\\nSaving model [{}]\".format('mortyfire'))\n",
"torch.save(model.state_dict(), 'mortyfire')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Script Generation"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"----- Temperatue: 0.6 -----\n",
"rick: ( burps ) \n",
" morty: fuck you, grandpa rick! you're an asshole. i can't believe you. i'm not going on a sigh for something. \n",
" summer: oh, uh. \n",
" jerry: oh, my god, our mother is going to be - - \n",
" rick: i don't know what i have to say what you didn't have to go back from that, \n",
" jerry: uh. how do you think morty? \n",
" summer: well, i'm sorry, i'm gonna go to jerry. \n",
" jerry: oh, you know, morty. i'm not gonna do whatever. \n",
" rick: what? \n",
" summer: i think we can do, rick. \n",
" rick: yeah, i m sorry. \n",
" jerry: but with the butterfly. \n",
" morty: right, i don t care. i think you should be a human planet. \n",
" [int. smith residence, kitchen - day] \n",
" rick, morty, and summer sit through the garage. the head pulls up. \n",
" morty: ( shouts ) you don t have you. \n",
" morty: no, i'm sorry, morty. i'm sorry. i'm not type you, morty. you'll be fine. \n",
" rick: yeah, i'm going to be a problem, \n",
" rick: what is where? \n",
" summer: shut up, morty! \n",
" summer: i'm sorry, \n",
" mr needful: i'm get to the garage! \n",
" [door to inside] \n",
" ( rick exits the great. ) \n",
" ( he looks up. ) \n",
" morty: oh, yeah, i'm not a good man. \n",
" rick: yeah, it's not not that's better to be fine, \n",
" rick: i'm sorry, \n",
" jerry: you know, i'm sorry, i'm sorry, \n",
" rick: you know, i'm gonna have to go. \n",
" rick: i'm the smartest. \n",
" beth: i'm sorry, i'm not a hack. i'm sorry. \n",
" morty: calm... \n",
" rick: oh, god, you're pretty different. \n",
" summer: what does i think? i mean, you might to be careful. \n",
" rick: i can t believe you re such. \n",
" morty: i don t know, you know, morty. you ve been a lot time, morty. i've got a lot place. \n",
" rick: i don't know, hey, i think i'm a pickle! i'm a good person! \n",
" rick: i'm sorry, i can get a new person of this, \n",
" summer: grandpa, i'm sorry, i'm not gonna tell that, summer! \n",
" morty: i don t know... \n",
" jerry: yeah, rick, i hope it. \n",
" ( morty and annie are having tied a tow and starts in the planet - he sees the gun by the sky. rick is in the middle of the train. \n",
" rick: what is you doing? \n",
" rick: you know what i can t go home. \n",
" summer: the other you guys. \n",
" [ext. earth - boobs's room - day] \n",
" rick and morty appear in the room. rick looks out of the room. \n",
" rick: ( to jerry ) do you do? \n",
" morty: i don t know, rick. i m a good. \n",
" [transition to morty's garage] \n",
" morty: [sighs] \n",
" morty: oh, no, i'm just even it's too, \n",
" rick: \" \n",
" morty: yeah, i'm not looking. \n",
" summer: what? \n",
" jerry: well, i think i don't know. i mean, i just want to come on, i'm still we're both your dad, \n",
" jerry: i can t believe, summer, i'm surrounded, right, morty, i just have been idea that and for that, \n",
" morty: yeah, i'm just saying, \n",
" morty: all right, okay, hey, i'm sorry, \n",
" beth: yeah, \n",
" morty: yeah, i think, i'm sorry. \n",
" rick: that was an one that word. \n",
" morty: rick. \n",
" [int. smith residence, living room - day] \n",
" rick and morty are running on the couch. he is wearing a portal. \n",
" rick: ( to beth ) what you got the clean to your game? \n",
" summer: what the heck was this? \n",
" rick: uh, you know what i m sayin to do that, \n",
" summer: what? \n",
" rick: i'm so sorry, but i'm a dumb person, \n",
" morty: what? \n",
" rick: what? \n",
" rick: i'm sorry, i'm sorry, i'm not sorry. \n",
" summer: dad, i'm the smartest. i'm in your life. you're gonna\n"
]
}
],
"source": [
"model_path = 'mortyfire'\n",
"model.load_state_dict(torch.load(model_path))\n",
"\n",
"start_sequence = \"rick: (burps)\\nmorty: fuck you, grandpa rick! you're an asshole.\"\n",
"temperature = 0.6\n",
"script_length = 1000\n",
"\n",
"script = generate(model, start_seq=start_sequence, vocab=vocab, temperature=temperature, length=script_length)\n",
"print('----- Temperatue: {} -----'.format(temperature))\n",
"print(script)"
]
},
{
"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.6.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment