ki-ljl / LSTM-IMDB-Classification

Use PyTorch to build an LSTM model for text classification on the IMDB dataset.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LSTM-IMDB-Classification

Use PyTorch to build an LSTM model for text classification on the IMDB dataset.

Environment

pytorch==1.10.1+cu111

numpy==1.18.5

pandas==1.2.3

Usage

  1. Download the glove.6B.50d.txt file from kaggle.
  2. Generate vocabulary_vectors.npy and word_list.npy:
if __name__ == '__main__':
    load_cab_vector()
  1. Generate sentence_code_1.npy and sentence_code_2.npy:
if __name__ == '__main__':
    # load_cab_vector()
    process_sentence('train')
    process_sentence('test')
  1. Generate training and test sets:
if __name__ == '__main__':
    # load_cab_vector()
    # process_sentence('train')
    # process_sentence('test')
    process_batch(batch_size=100)
  1. Model training and testing:
if __name__ == '__main__':
    train()
    test()
    # load_cab_vector()
    # process_sentence('train')
    # process_sentence('test')
    # process_batch(100)

About

Use PyTorch to build an LSTM model for text classification on the IMDB dataset.