Skip to content

Instantly share code, notes, and snippets.

@Tiriree
Last active April 3, 2018 04:46
Show Gist options
  • Save Tiriree/42cb739f3e88425e9ee9b716dba020d0 to your computer and use it in GitHub Desktop.
Save Tiriree/42cb739f3e88425e9ee9b716dba020d0 to your computer and use it in GitHub Desktop.
DeepTalking description using Neural network text prediction with textgenrnn Inspired by Allison Parrish Reading and Writing Electronic Text class Link to her tutorial What is Textgenrnn From Max Woolf's Github textgenrnn is a Python 3 module on top of Keras/TensorFlow which can easily generate text using a pretrained recurrent neural network Si…
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## DeepTalking description using Neural network text prediction with `textgenrnn`\n",
"\n",
"Inspired by [Allison Parrish](http://www.decontextualize.com/) Reading and Writing Electronic Text class\n",
"Link to her [tutorial](https://github.com/aparrish/rwet/blob/master/neural-network-text-prediction-with-textgenrnn.ipynb)\n",
"\n",
"What is Textgenrnn [From Max Woolf's Github](https://github.com/minimaxir/textgenrnn/blob/master/README.md)\n",
" \n",
" textgenrnn is a Python 3 module on top of Keras/TensorFlow which can easily generate text using a pretrained recurrent neural network\n",
" \n",
"Since I have been working a lot on the machine generate text and poem for my thesis. Why don't I generate a description of the show using neural network text prediction? \n",
"\n",
"Part of my show is going to be an unpredictable script. I wanted to give an audience a hint that my show will be many of improvisation."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Solving environment: done\n",
"\n",
"# All requested packages already installed.\n",
"\n"
]
}
],
"source": [
"!conda install -y keras"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: textgenrnn in /Users/tiri/anaconda3/lib/python3.6/site-packages\n",
"Requirement already satisfied: tensorflow in /Users/tiri/anaconda3/lib/python3.6/site-packages (from textgenrnn)\n",
"Requirement already satisfied: keras in /Users/tiri/anaconda3/lib/python3.6/site-packages (from textgenrnn)\n",
"Requirement already satisfied: h5py in /Users/tiri/anaconda3/lib/python3.6/site-packages (from textgenrnn)\n",
"Requirement already satisfied: numpy>=1.11.0 in /Users/tiri/anaconda3/lib/python3.6/site-packages (from tensorflow->textgenrnn)\n",
"Requirement already satisfied: werkzeug>=0.11.10 in /Users/tiri/anaconda3/lib/python3.6/site-packages (from tensorflow->textgenrnn)\n",
"Requirement already satisfied: wheel>=0.26 in /Users/tiri/anaconda3/lib/python3.6/site-packages (from tensorflow->textgenrnn)\n",
"Requirement already satisfied: protobuf>=3.2.0 in /Users/tiri/anaconda3/lib/python3.6/site-packages (from tensorflow->textgenrnn)\n",
"Requirement already satisfied: six>=1.10.0 in /Users/tiri/anaconda3/lib/python3.6/site-packages (from tensorflow->textgenrnn)\n",
"Requirement already satisfied: scipy>=0.14 in /Users/tiri/anaconda3/lib/python3.6/site-packages (from keras->textgenrnn)\n",
"Requirement already satisfied: pyyaml in /Users/tiri/anaconda3/lib/python3.6/site-packages (from keras->textgenrnn)\n",
"Requirement already satisfied: setuptools in /Users/tiri/anaconda3/lib/python3.6/site-packages (from protobuf>=3.2.0->tensorflow->textgenrnn)\n"
]
}
],
"source": [
"!pip install textgenrnn"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Using TensorFlow backend.\n"
]
}
],
"source": [
"from textgenrnn import textgenrnn"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"textgen = textgenrnn()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The body the street to the stream and he was a protest in the states and should be a beautiful to the same for the first time to the stream and the most car to the stream to the things who got a sta\n",
"\n"
]
}
],
"source": [
"textgen.generate()"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Epoch 1/25\n",
"2578/2578 [==============================] - 3s 1ms/step - loss: 0.1891\n",
"Epoch 2/25\n",
"2578/2578 [==============================] - 3s 1ms/step - loss: 0.3043\n",
"Epoch 3/25\n",
"2578/2578 [==============================] - 3s 1ms/step - loss: 0.2723\n",
"Epoch 4/25\n",
"2578/2578 [==============================] - 3s 1ms/step - loss: 0.2571\n",
"Epoch 5/25\n",
"2578/2578 [==============================] - 3s 1ms/step - loss: 0.2081\n",
"Epoch 6/25\n",
"2578/2578 [==============================] - 3s 1ms/step - loss: 0.1786\n",
"Epoch 7/25\n",
"2578/2578 [==============================] - 3s 1ms/step - loss: 0.1669\n",
"Epoch 8/25\n",
"2578/2578 [==============================] - 3s 1ms/step - loss: 0.1466\n",
"Epoch 9/25\n",
"2578/2578 [==============================] - 3s 1ms/step - loss: 0.1352\n",
"Epoch 10/25\n",
"2578/2578 [==============================] - 3s 1ms/step - loss: 0.1293\n",
"Epoch 11/25\n",
"2578/2578 [==============================] - 3s 1ms/step - loss: 0.1207\n",
"Epoch 12/25\n",
"2578/2578 [==============================] - 3s 1ms/step - loss: 0.1165\n",
"Epoch 13/25\n",
"2578/2578 [==============================] - 3s 1ms/step - loss: 0.1141\n",
"Epoch 14/25\n",
"2578/2578 [==============================] - 3s 1ms/step - loss: 0.1109\n",
"Epoch 15/25\n",
"2578/2578 [==============================] - 3s 1ms/step - loss: 0.1084\n",
"Epoch 16/25\n",
"2578/2578 [==============================] - 3s 1ms/step - loss: 0.1062\n",
"Epoch 17/25\n",
"2578/2578 [==============================] - 3s 1ms/step - loss: 0.1043\n",
"Epoch 18/25\n",
"2578/2578 [==============================] - 3s 1ms/step - loss: 0.1027\n",
"Epoch 19/25\n",
"2578/2578 [==============================] - 3s 1ms/step - loss: 0.1014\n",
"Epoch 20/25\n",
"2578/2578 [==============================] - 3s 1ms/step - loss: 0.1002\n",
"Epoch 21/25\n",
"2578/2578 [==============================] - 3s 1ms/step - loss: 0.0993\n",
"Epoch 22/25\n",
"2578/2578 [==============================] - 3s 1ms/step - loss: 0.0984\n",
"Epoch 23/25\n",
"2578/2578 [==============================] - 3s 1ms/step - loss: 0.0976\n",
"Epoch 24/25\n",
"2578/2578 [==============================] - 3s 1ms/step - loss: 0.0970\n",
"Epoch 25/25\n",
"2578/2578 [==============================] - 3s 1ms/step - loss: 0.0966\n"
]
}
],
"source": [
"textgen.train_on_texts(open(\"deeptalkingText.txt\").readlines(), num_epochs=25)"
]
},
{
"cell_type": "code",
"execution_count": 48,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n",
"\n"
]
}
],
"source": [
"textgen.generate()"
]
},
{
"cell_type": "code",
"execution_count": 49,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"text = open(\"deeptalkingdetail.txt\").read()"
]
},
{
"cell_type": "code",
"execution_count": 50,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\"DeepTalking\\nTiri's Thesis Performance\\nPerformers\\n January Punwattana\\n Tiri Kananuruk\\nSunday, April 8, 2018: 7 pm --- Free event\\n The Riese Lounge - NYU Tisch school of the Arts\\n 721 Broadway New York NY 10003\\nRSVP here --- https://goo.gl/forms/XhMLxVXSs04FSNzv2\\nFacebook event --- https://bit.ly/2GuHjCE\\n\""
]
},
"execution_count": 50,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"text"
]
},
{
"cell_type": "code",
"execution_count": 56,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"DeepTalking\n",
"Tiri's Thesis Performance\n",
"Performers\n",
" January Punwattana\n",
" Tiri Kananuruk\n",
"Sunday, April 8, 2018: 7 pm --- Free event\n",
" The Riese Lounge - NYU Tisch school of the Arts\n",
" 721 Broadway New York NY 10003\n",
"RSVP here --- https://goo.gl/forms/XhMLxVXSs04FSNzv2\n",
"Facebook event --- https://bit.ly/2GuHjCE\n",
"\n",
"DeepTalking\n",
"DeepTalking\n",
"\n",
"---- We try to build machines to look as life-like as possible, ones that can learn and sound through machines, and I often commit mistakes live. This forces a process of learn and learn from feed\n",
"\n",
"- pre-recording performances. How can I utilize this process within my own artistic process make mistakes, this translates to be trained just like interestit now and computing for performance. Tode\n",
"\n",
"\n",
"\n",
"\n"
]
}
],
"source": [
"print(text)\n",
"deepTalking_description = textgen.generate(10, temperature=0.8, return_as_list=True)\n",
"for line in deepTalking_description:\n",
" print(line.strip())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### My favorite result of trying for 20 times\n",
"\n",
" DeepTalking\n",
" Tiri's Thesis Performance\n",
"\n",
" Performers\n",
" January Punwattana\n",
" Tiri Kananuruk\n",
"\n",
" Sunday, April 8, 2018: 7 pm --- Free event\n",
" The Riese Lounge - NYU Tisch school of the Arts\n",
" 721 Broadway New York NY 10003\n",
" RSVP here --- https://goo.gl/forms/XhMLxVXSs04FSNzv2\n",
" Facebook event --- https://bit.ly/2GuHjCE\n",
"\n",
"\n",
" DeepTirininating to New York worked or programming and mistakes for experiences.\n",
"\n",
"\n",
" During my performances, my collaborators, and I happertists to learn at errors with look as new art pre-result performers an an expering my and machines to dirn within toal improvisation creates imp\n",
" Personal Statement:\n",
"\n",
"\n",
" I found that the would with computing signalph abseticler, things have discovered ways of turning it into improvisation. To result to process we signal machines like is a human? What determines if l\n",
" ---- Tiri Kananuruk As a world almost solve a way to misinform and have intelligent within the artistic creative process within my own artistic can glitch a brokeh interesting art an artistic be a\n",
" Description:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"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.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment