LSTM and CNN sentiment analysis in PyTorch
The sentiment model is trained on Stanford Sentiment Treebank (i.e. SST2).
- torch
- torchtext
- tdqm
- torchwordemb
pip install torchwordemb
LSTM and CNN sentiment analysis
i've got this error:
Train epoch 1: 0%| | 0/1384 [00:00<?, ?it/s]
Traceback (most recent call last):
File "train_batch.py", line 200, in
avg_loss, acc = train_epoch_progress(model, train_iter, loss_function, optimizer, text_field, label_field, epoch)
File "train_batch.py", line 64, in train_epoch_progress
pred = model(sent)
File "/home/luisfredgs/anaconda3/envs/MachineLearning/lib/python3.5/site-packages/torch/nn/modules/module.py", line 357, in call
result = self.forward(*input, **kwargs)
File "/home/luisfredgs/Documentos/machine-learning/nlp/pytorch/pytorch-sentiment-classification/lstm.py", line 31, in forward
x = self.embeddings(sentence).view(len(sentence), self.batch_size, -1)
File "/home/luisfredgs/anaconda3/envs/MachineLearning/lib/python3.5/site-packages/torch/nn/modules/module.py", line 357, in call
result = self.forward(*input, **kwargs)
File "/home/luisfredgs/anaconda3/envs/MachineLearning/lib/python3.5/site-packages/torch/nn/modules/sparse.py", line 103, in forward
self.scale_grad_by_freq, self.sparse
File "/home/luisfredgs/anaconda3/envs/MachineLearning/lib/python3.5/site-packages/torch/nn/_functions/thnn/sparse.py", line 59, in forward
output = torch.index_select(weight, 0, indices.view(-1))
TypeError: torch.index_select received an invalid combination of arguments - got (torch.cuda.FloatTensor, int, torch.LongTensor), but expected (torch.cuda.FloatTensor source, int dim, torch.cuda.LongTensor index)
Could you help?
Hi, what did you do for data preprocessing? I deal with sentence-level sentiment classification on BiLSTM. The accuracy is 86% on your dataset, but 82% on the dataset downloaded from the official website. I found that all strings were converted to lowercase and special characters were deleted. Is there anything else?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.