anubhavgupta3377 / text-classification-models-pytorch Goto Github PK
View Code? Open in Web Editor NEWImplementation of State-of-the-art Text Classification Models in Pytorch
License: MIT License
Implementation of State-of-the-art Text Classification Models in Pytorch
License: MIT License
In fasttext model:
def forward(self, x):
embedded_sent = self.embeddings(x).permute(1,0,2)
h = self.fc1(embedded_sent.mean(1))
z = self.fc2(h)
return self.softmax(z)
Why is there no call to relu on h?
I don't know why , I just add the code in config.py
max_sen_len = None
can you give me some ideas,thanks
hi, setting max_length to none, but short sentence would still be padded to the longest length among the batch, thus affects the training and prediction result
eg.
predict only one sentence, "0516酸菜鱼", index input to tensor([[241542],
[ 7789],
[ 192],
[ 260]])
but add "'Bird&Bird 香港鸿鹄律师事务所北京代表处鸿鹄知识产权代理(北京有限公司)'
index input to ":
whereas index 1 is "<pad>"
and output differs:
Hi, would you please share your point in "Only encoder part of Transformer model is used for classification",.
I apply this model in my dataset, the accuracy only 60% .I am thinking whether the number of layer is a cause?
On lines 53 and 61 of Text-Classification-Models-Pytorch/Model_RCNN/model.py
, function permute
is used.
input_features = torch.cat([lstm_out,embedded_sent], 2).permute(1,0,2)
...
linear_output = linear_output.permute(0,2,1) # Reshaping fot max_pool
Could you please explain why it is necessary or useful to permute the dimensions of these tensors?
use Model_Transformer
when I run train.py,I got as follow:
TypeError: forward() missing 1 required positional argument: 'mask'
Can you give me the reason?
Hi, when i run the train.py in the folder "textCNN model",there is an error that I cant find out what's wrong. Can you help me ? Thank you very much
Loaded 96000 training examples
Loaded 7600 test examples
Loaded 24000 validation examples
Epoch: 0
Traceback (most recent call last):
File "/Users/y/Documents/Code/Text-Classification-Models-Pytorch-master/Model_TextCNN/train.py", line 43, in <module>
train_loss,val_accuracy = model.run_epoch(dataset.train_iterator, dataset.val_iterator, i)
File "/Users/y/Documents/Code/Text-Classification-Models-Pytorch-master/Model_TextCNN/model.py", line 85, in run_epoch
y_pred = self.__call__(x)
File "/anaconda3/python.app/Contents/lib/python3.6/site-packages/torch/nn/modules/module.py", line 489, in __call__
result = self.forward(*input, **kwargs)
File "/Users/y/Documents/Code/Text-Classification-Models-Pytorch-master/Model_TextCNN/model.py", line 45, in forward
embedded_sent = self.embeddings(x).permute(1,2,0)
File "/anaconda3/python.app/Contents/lib/python3.6/site-packages/torch/nn/modules/module.py", line 489, in __call__
result = self.forward(*input, **kwargs)
File "/anaconda3/python.app/Contents/lib/python3.6/site-packages/torch/nn/modules/sparse.py", line 118, in forward
self.norm_type, self.scale_grad_by_freq, self.sparse)
File "/anaconda3/python.app/Contents/lib/python3.6/site-packages/torch/nn/functional.py", line 1454, in embedding
return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
RuntimeError: index out of range at /Users/administrator/nightlies/pytorch-1.0.0/wheel_build_dirs/conda_3.6/conda/conda-bld/pytorch_1544137972173/work/aten/src/TH/generic/THTensorEvenMoreMath.cpp:191
Process finished with exit code 1
Hi, thanks for your code! However, I think there might be a bug on NLLLoss: I think the input of nn.NLLloss() is after logsoftmax according to this manual: https://pytorch.org/docs/stable/generated/torch.nn.NLLLoss.html, however, here only softmax is provided in model.py therefore, the loss is always negative. I only check the Transformer model.
Kind regards,
John
Hi,
What are the files named "ag_news.train" and "ag_news.test"?
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.