Skip to content

Instantly share code, notes, and snippets.

View sohamshashank1's full-sized avatar

Shashank sohamshashank1

View GitHub Profile
@sohamshashank1
sohamshashank1 / loadModel.py
Created April 3, 2018 03:45 — forked from vgpena/loadModel.py
Basic text classification with Keras and TensorFlow
import json
import numpy as np
import keras
import keras.preprocessing.text as kpt
from keras.preprocessing.text import Tokenizer
from keras.models import model_from_json
# we're still going to use a Tokenizer here, but we don't need to fit it
tokenizer = Tokenizer(num_words=3000)
# for human-friendly printing
@sohamshashank1
sohamshashank1 / gist:2d0f6e495acc5da587917a679e56841d
Last active March 29, 2018 17:51
Text Classification with RNN
## Objective to to classify text/ sentences using RNN
## IMDB dataset is considered which contains 25,000 highly-polar movie reviews (good or bad) for training and the same amount again for testing. The problem is to determine whether a given movie review has a positive or negative sentiment.
```
# LSTM for sequence classification in the IMDB dataset
import numpy
from keras.datasets import imdb
from keras.models import Sequential
from keras.layers import Dense
from keras.layers import LSTM