Skip to content

Commit

Permalink
LSTM on books data
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Sep 15, 2017
1 parent 48c46de commit 835fa6b
Show file tree
Hide file tree
Showing 2 changed files with 267 additions and 73 deletions.
9 changes: 6 additions & 3 deletions hatt_train.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"deletable": true,
"editable": true
},
"source": [
"The code in this notebook is based on [Richard Liao's implementation of hierarchical attention networks](https://github.com/richliao/textClassifier/blob/master/textClassifierHATT.py) and a related [Google group discussion](https://groups.google.com/forum/#!topic/keras-users/IWK9opMFavQ). The notebook also includes code from [Keras documentation](https://keras.io/) and [blog](https://blog.keras.io/using-pre-trained-word-embeddings-in-a-keras-model.html) as well as this [word2vec tutorial](http://adventuresinmachinelearning.com/gensim-word2vec-tutorial/)."
]
Expand Down Expand Up @@ -171,11 +174,11 @@
"texts = []\n",
"\n",
"for idx in range(train_data.shape[0]):\n",
" text = train_data['text'][idx]\n",
" text = train_data['text'].iloc[idx]\n",
" texts.append(text)\n",
" sentences = nltk.tokenize.sent_tokenize(text)\n",
" reviews.append(sentences)\n",
" labels.append(train_data['rating'][idx])"
" labels.append(train_data['rating'].iloc[idx])"
]
},
{
Expand Down
Loading

0 comments on commit 835fa6b

Please sign in to comment.