Binary text classification on IMDB movie reviews — positive or negative.
| Model | AVG Test Accuracy |
|---|---|
| BiLSTM | ~87% |
| RNN | ~68% |
| GRU | ~89% |
Input Text
↓
Tokenization
↓
Embedding Layer
↓
Model
↓
Concatenate
↓
Dropout (0.4)
↓
Linear Layer
↓
Sigmoid → probability (>0.5 = Positive)
- Word Embeddings
- Padding & Packing sequences
- Vanishing Gradients
- LSTM Gates (forget, input, output)
- Bidirectional LSTM
- Gradient Clipping
- GRU
- RNN
pip install torch datasets
python sentiment_LSTM.pypip install torch datasets
python sentiment_Model.py- Epoch 1/10
- Train loss: 0.66|Train Acc: 0.59
- Test loss: 0.77| Test acc: 0.51
- one scene is good but the movie is worst NEG (confidence: 0.01)
- this was an absolutely brilliant masterpiece POS (confidence: 0.97)
- terrible boring waste of my time NEG (confidence: 0.01)
- one scene is good but the movie is worst Positive (confidence: 0.92)
- this was an absolutely brilliant masterpiece Negative (confidence: 0.27)
- terrible boring waste of my time Negative (confidence: 0.01)
- one scene is good but the movie is worst Negative (confidence: 0.00)
- this was an absolutely brilliant masterpiece Positive (confidence: 1.00)
- terrible boring waste of my time Negative (confidence: 0.00)
Vikas Reddy
- GitHub: @vikasreddy11
- LinkedIn: Vikas Reddy