GithubHelp home page GithubHelp logo

Comments (3)

LiyuanLucasLiu avatar LiyuanLucasLiu commented on May 25, 2024

It would be great if you can give more details about the question. i'm not sure whether i get it or not

from lm-lstm-crf.

ZhixiuYe avatar ZhixiuYe commented on May 25, 2024

oh, sorry,
For example, in https://github.com/spro/practical-pytorch/blob/master/seq2seq-translation/seq2seq-translation-batched.ipynb , the function 'forward' in class 'EncoderRNN'
packed = torch.nn.utils.rnn.pack_padded_sequence(embedded, input_lengths)
outputs, hidden = self.gru(packed, hidden)
outputs, output_lengths = torch.nn.utils.rnn.pad_packed_sequence(outputs) # unpack (back to padded)
it packs a batch of sentences firstly, and then uses gru.
And you do it in this way:
outputs, hidden = self.gru(embedded, hidden)
And I just want to know why you do not pack them, and what is the difference between using pack_padded_sequence or not.
thank you!

from lm-lstm-crf.

LiyuanLucasLiu avatar LiyuanLucasLiu commented on May 25, 2024

Get it!
it's essentially due to a advanced feature of PyTorch, which is padded sequences of variable length.

In our code, we manually conducted the padding, and do not need to use this function (since i've heard that the padded sequence would cause inefficiency, but i'm not sure). And it seems that the example you refers use this technique. This is why i do not pack them, and they need to.

from lm-lstm-crf.

Related Issues (20)

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.