Skip to content

Commit

Permalink
Typo and Fix in MultiModal Nets + Index Notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
leriomaggio committed Apr 13, 2017
1 parent 41ec326 commit 5d4fa64
Show file tree
Hide file tree
Showing 6 changed files with 192 additions and 150 deletions.
16 changes: 5 additions & 11 deletions 2.4 Transfer Learning & Fine-Tuning.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stderr",
Expand Down Expand Up @@ -106,7 +104,7 @@
},
"outputs": [],
"source": [
"if K.image_dim_ordering() == 'th':\n",
"if K.image_data_format() == 'channels_first':\n",
" input_shape = (1, img_rows, img_cols)\n",
"else:\n",
" input_shape = (img_rows, img_cols, 1)"
Expand Down Expand Up @@ -214,9 +212,7 @@
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -255,9 +251,7 @@
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -361,7 +355,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
"version": "3.5.3"
}
},
"nbformat": 4,
Expand Down
22 changes: 16 additions & 6 deletions Extra Additional Materials.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,23 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
"source": [
"- [Perceptron and Adaline Implementation](./additional materials/1.1.1 Perceptron and Adaline.ipynb)\n",
"\n",
"- [MLP and MNIST](./additional materials/1.1.2 MLP and MNIST.ipynb)\n",
"\n",
"- [Quick Theano Tutorial](./additional materials/1.5.1 Introduction - Theano.ipynb)\n",
"\n",
"- [LSTM for Sentence Generation](./additional materials/3.3 LSTM for Sentence Generation.ipynb)\n",
"\n",
"- [Custom Layers in Keras](./additional materials/5.1 Custom Layer.ipynb)\n",
"\n",
"- [Multi-Modal Networks](./additional materials/5.2 Multi-Modal Networks.ipynb)"
]
}
],
"metadata": {
Expand All @@ -33,9 +43,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
"version": "3.5.3"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}
105 changes: 27 additions & 78 deletions additional materials/3.3 LSTM for Sentence Generation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"metadata": {},
"source": [
"\n",
"# RNN using LSTM \n",
Expand Down Expand Up @@ -44,9 +42,7 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"from keras.optimizers import SGD\n",
Expand Down Expand Up @@ -82,9 +78,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"DATA_DIRECTORY = os.path.join(os.path.abspath(os.path.curdir), '..', 'data', 'word_embeddings')\n",
Expand Down Expand Up @@ -121,9 +115,7 @@
{
"cell_type": "code",
"execution_count": 85,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"filtered_male_posts = list(filter(lambda p: len(p) > 0, male_posts))\n",
Expand All @@ -133,9 +125,7 @@
{
"cell_type": "code",
"execution_count": 86,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"# text processing - one hot builds index of the words\n",
Expand All @@ -158,9 +148,7 @@
{
"cell_type": "code",
"execution_count": 87,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"# 0 for male, 1 for female\n",
Expand All @@ -171,9 +159,7 @@
{
"cell_type": "code",
"execution_count": 88,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"from sklearn.cross_validation import train_test_split\n",
Expand All @@ -186,9 +172,7 @@
{
"cell_type": "code",
"execution_count": 89,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand All @@ -210,9 +194,7 @@
{
"cell_type": "code",
"execution_count": 90,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"max_features = 30000\n",
Expand All @@ -229,9 +211,7 @@
{
"cell_type": "code",
"execution_count": 91,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"model.compile(loss='mean_squared_error', optimizer='sgd', metrics=['accuracy'])"
Expand All @@ -240,9 +220,7 @@
{
"cell_type": "code",
"execution_count": 92,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -278,9 +256,7 @@
{
"cell_type": "code",
"execution_count": 93,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand All @@ -297,9 +273,7 @@
{
"cell_type": "code",
"execution_count": 94,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -334,9 +308,7 @@
{
"cell_type": "code",
"execution_count": 96,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"vectorizer = TfidfVectorizer(decode_error='ignore', norm='l2', min_df=5)\n",
Expand All @@ -347,9 +319,7 @@
{
"cell_type": "code",
"execution_count": 97,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"flattened_array_tfidf_male = tfidf_male.toarray()\n",
Expand All @@ -359,9 +329,7 @@
{
"cell_type": "code",
"execution_count": 98,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"y_rnn = np.concatenate((np.zeros(len(flattened_array_tfidf_male)),\n",
Expand All @@ -371,9 +339,7 @@
{
"cell_type": "code",
"execution_count": 99,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"X_train_rnn, X_test_rnn, y_train_rnn, y_test_rnn = train_test_split(np.concatenate((flattened_array_tfidf_male, \n",
Expand All @@ -384,9 +350,7 @@
{
"cell_type": "code",
"execution_count": 100,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -436,9 +400,7 @@
{
"cell_type": "code",
"execution_count": 103,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -475,9 +437,7 @@
{
"cell_type": "code",
"execution_count": 104,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand All @@ -495,9 +455,7 @@
{
"cell_type": "code",
"execution_count": 105,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand All @@ -521,9 +479,7 @@
{
"cell_type": "code",
"execution_count": 106,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"# reading all the male text data into one string\n",
Expand All @@ -549,9 +505,7 @@
{
"cell_type": "code",
"execution_count": 107,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -580,9 +534,7 @@
{
"cell_type": "code",
"execution_count": 109,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand All @@ -608,9 +560,7 @@
{
"cell_type": "code",
"execution_count": 74,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"auto_text_generating_male_model.compile(loss='mean_squared_error',optimizer='sgd')"
Expand Down Expand Up @@ -649,7 +599,6 @@
"cell_type": "code",
"execution_count": 113,
"metadata": {
"collapsed": false,
"scrolled": false
},
"outputs": [
Expand Down Expand Up @@ -940,9 +889,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
"version": "3.5.3"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}
Loading

0 comments on commit 5d4fa64

Please sign in to comment.