Use PyTorch to build an LSTM model for text classification on the IMDB dataset.
pytorch==1.10.1+cu111
numpy==1.18.5
pandas==1.2.3
- Download the glove.6B.50d.txt file from kaggle.
- Generate vocabulary_vectors.npy and word_list.npy:
if __name__ == '__main__':
load_cab_vector()
- Generate sentence_code_1.npy and sentence_code_2.npy:
if __name__ == '__main__':
# load_cab_vector()
process_sentence('train')
process_sentence('test')
- Generate training and test sets:
if __name__ == '__main__':
# load_cab_vector()
# process_sentence('train')
# process_sentence('test')
process_batch(batch_size=100)
- Model training and testing:
if __name__ == '__main__':
train()
test()
# load_cab_vector()
# process_sentence('train')
# process_sentence('test')
# process_batch(100)