Code Monkey home page Code Monkey logo

pytorch-rnn-text-classification's Introduction

RNN-based short text classification

  • This is for multi-class short text classification.
  • Model is built with Word Embedding, LSTM ( or GRU), and Fully-connected layer by Pytorch.
  • A mini-batch is created by 0 padding and processed by using torch.nn.utils.rnn.PackedSequence.
  • Cross-entropy Loss + Adam optimizer.
  • Support pretrained word embedding (GloVe).

Model

  • Embedding --> Dropout --> LSTM(GRU) --> Dropout --> FC.

Preprocessing

python preprocess.py

Training

  • The following command starts training. Run it with -h for optional arguments.
python main.py

pytorch-rnn-text-classification's People

Contributors

anirudh257 avatar dependabot[bot] avatar keishinkickback avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pytorch-rnn-text-classification's Issues

UnicodeDecodeError: 'gbk' codec can't decode byte 0xa2 in position 4759: illegal multibyte sequence

When i run the ''process.py'', i got the error at
'create_tsv_file('data-web-snippets/train.txt', 'data/train.tsv')':

  File "H:/my work/Pytorch-RNN-text-classification-master\util.py", line 21, in create_tsv_file
    for line in f:
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa2 in position 4759: illegal multibyte sequence

i wonder why i use the same download txt but went wrong??
thank u.

TypeError: new(): data must be a sequence (got map)

Which Python version should I use?

When I used Python3 run the main.py I got an error:
Traceback (most recent call last):
File "main.py", line 179, in
train(train_loader, model, criterion, optimizer, epoch)
File "main.py", line 102, in train
for i, (input, target, seq_lengths) in enumerate(train_loader):
File "/media/yu/Work/ml/dl/case/Pytorch-RNN-text-classification-master/dataloader.py", line 108, in iter
yield self._create_batch()
File "/media/yu/Work/ml/dl/case/Pytorch-RNN-text-classification-master/dataloader.py", line 82, in _create_batch
seq_lengths = torch.LongTensor(map(len, string))
TypeError: new(): data must be a sequence (got map)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.