diff --git a/module1-rnn-and-lstm/LS_DS_431_RNN_and_LSTM_Assignment.ipynb b/module1-rnn-and-lstm/LS_DS_431_RNN_and_LSTM_Assignment.ipynb
index a49e3827..28178d35 100644
--- a/module1-rnn-and-lstm/LS_DS_431_RNN_and_LSTM_Assignment.ipynb
+++ b/module1-rnn-and-lstm/LS_DS_431_RNN_and_LSTM_Assignment.ipynb
@@ -1,7 +1,50 @@
{
+ "nbformat": 4,
+ "nbformat_minor": 0,
+ "metadata": {
+ "kernelspec": {
+ "display_name": "U4-S3-MNA-DS11",
+ "language": "python",
+ "name": "u4-s3-mna-ds11"
+ },
+ "language_info": {
+ "name": "python",
+ "version": "3.7.0",
+ "mimetype": "text/x-python",
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "pygments_lexer": "ipython3",
+ "nbconvert_exporter": "python",
+ "file_extension": ".py"
+ },
+ "nteract": {
+ "version": "0.23.3"
+ },
+ "colab": {
+ "name": "LS_DS_431_RNN_and_LSTM_Assignment.ipynb",
+ "provenance": [],
+ "include_colab_link": true
+ }
+ },
"cells": [
{
"cell_type": "markdown",
+ "metadata": {
+ "id": "view-in-github",
+ "colab_type": "text"
+ },
+ "source": [
+ ""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "2eNX0cl4gdlk",
+ "colab_type": "text"
+ },
"source": [
"
\n",
"
\n",
@@ -22,28 +65,63 @@
"Then, use that trained RNN to generate Shakespearean-ish text. Your goal - a function that can take, as an argument, the size of text (e.g. number of characters or lines) to generate, and returns generated text of that size.\n",
"\n",
"Note - Shakespeare wrote an awful lot. It's OK, especially initially, to sample/use smaller data and parameters, so you can have a tighter feedback loop when you're trying to get things running. Then, once you've got a proof of concept - start pushing it more!"
- ],
- "metadata": {}
+ ]
},
{
"cell_type": "code",
+ "metadata": {
+ "id": "e69dwdA2RB1W",
+ "colab_type": "code",
+ "colab": {}
+ },
"source": [
- "import requests\n",
- "import pandas as pd"
+ "from tensorflow.keras.callbacks import LambdaCallback\n",
+ "from tensorflow.keras.models import Sequential\n",
+ "from tensorflow.keras.layers import Dense, LSTM\n",
+ "from tensorflow.keras.optimizers import RMSprop\n",
+ "\n",
+ "import numpy as np\n",
+ "import random\n",
+ "import sys\n",
+ "import os"
],
- "outputs": [],
"execution_count": 1,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
"metadata": {
"execution": {
"iopub.status.busy": "2020-06-15T18:18:20.442Z",
"iopub.execute_input": "2020-06-15T18:18:20.453Z",
"iopub.status.idle": "2020-06-15T18:18:20.513Z",
"shell.execute_reply": "2020-06-15T18:18:20.523Z"
- }
- }
+ },
+ "id": "3YO7WBitgdll",
+ "colab_type": "code",
+ "colab": {}
+ },
+ "source": [
+ "import requests\n",
+ "import pandas as pd\n",
+ "import numpy as np"
+ ],
+ "execution_count": 2,
+ "outputs": []
},
{
"cell_type": "code",
+ "metadata": {
+ "execution": {
+ "iopub.status.busy": "2020-06-15T18:25:49.778Z",
+ "iopub.execute_input": "2020-06-15T18:25:49.781Z",
+ "iopub.status.idle": "2020-06-15T18:25:51.467Z",
+ "shell.execute_reply": "2020-06-15T18:25:51.469Z"
+ },
+ "id": "BtATGHyUgdln",
+ "colab_type": "code",
+ "colab": {}
+ },
"source": [
"url = \"https://www.gutenberg.org/files/100/100-0.txt\"\n",
"\n",
@@ -77,43 +155,44 @@
"\n",
"df_toc['text'] = df_toc.apply(lambda x: '\\r\\n'.join(data[ x['start'] : int(x['end']) ]), axis=1)"
],
- "outputs": [],
- "execution_count": 23,
- "metadata": {
- "execution": {
- "iopub.status.busy": "2020-06-15T18:25:49.778Z",
- "iopub.execute_input": "2020-06-15T18:25:49.781Z",
- "iopub.status.idle": "2020-06-15T18:25:51.467Z",
- "shell.execute_reply": "2020-06-15T18:25:51.469Z"
- }
- }
+ "execution_count": 3,
+ "outputs": []
},
{
"cell_type": "code",
+ "metadata": {
+ "jupyter": {
+ "source_hidden": false,
+ "outputs_hidden": false
+ },
+ "nteract": {
+ "transient": {
+ "deleting": false
+ }
+ },
+ "execution": {
+ "iopub.status.busy": "2020-06-15T18:26:12.630Z",
+ "iopub.execute_input": "2020-06-15T18:26:12.637Z",
+ "iopub.status.idle": "2020-06-15T18:26:12.643Z",
+ "shell.execute_reply": "2020-06-15T18:26:12.647Z"
+ },
+ "id": "JMVbv0RLgdlp",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 195
+ },
+ "outputId": "ffa55942-775a-496e-f6c4-4d68765d9cc9"
+ },
"source": [
"#Shakespeare Data Parsed by Play\n",
"df_toc.head()"
],
+ "execution_count": 4,
"outputs": [
{
"output_type": "execute_result",
- "execution_count": 24,
"data": {
- "text/plain": [
- " title start end \\\n",
- "0 ALL’S WELL THAT ENDS WELL 2777 7738 \n",
- "1 THE TRAGEDY OF ANTONY AND CLEOPATRA 7739 11840 \n",
- "2 AS YOU LIKE IT 11841 14631 \n",
- "3 THE COMEDY OF ERRORS 14632 17832 \n",
- "4 THE TRAGEDY OF CORIOLANUS 17833 27806 \n",
- "\n",
- " text \n",
- "0 ALL’S WELL THAT ENDS WELL\\r\\n\\r\\n\\r\\n\\r\\nConte... \n",
- "1 THE TRAGEDY OF ANTONY AND CLEOPATRA\\r\\n\\r\\nDRA... \n",
- "2 AS YOU LIKE IT\\r\\n\\r\\nDRAMATIS PERSONAE.\\r\\n\\r... \n",
- "3 THE COMEDY OF ERRORS\\r\\n\\r\\n\\r\\n\\r\\nContents\\r... \n",
- "4 THE TRAGEDY OF CORIOLANUS\\r\\n\\r\\nDramatis Pers... "
- ],
"text/html": [
"