Git Product home page Git Product logo

Comments (4)

nelson-liu avatar nelson-liu commented on August 16, 2024

I've thought about this a bit, and I used to think that sorting should be part of the data code. Now, I'm not so sure. Say you're doing inference --- you need your batches to be in sorted order, but they don't come in sorted order. If you sort within a batch using torchtext, it seems excessive for torchtext to provide an API for unshuffling your batch predictions (since what good are predictions if they're in random order wrt the input?)

Long story short, I sort the batches in my code, vs relying on torchtext to do it. It's pretty speedy so I haven't had a reason to complain (yet)

Regardless, I wouldn't call this a bug, more a design decision...

from text.

PetrochukM avatar PetrochukM commented on August 16, 2024

@nelson-liu Not sure we're on the same page.

Do not think I am asking for: "torchtext to provide an API for unshuffling your batch predictions"
Not asking for this either "sort the batches".

Specifically, I am referencing sorting the sequences within a batch by decreasing lengths for both inference and training. For example:

Batch[
   "1 2 3"
   "1 2 3 4 5"
   "1 2 3 4"
]

Will throw an error with torch.RNN and pack_padded_sequence unless the batch is sorted by decreasing lengths:

Batch[
   "1 2 3 4 5"
   "1 2 3 4"
   "1 2 3"
]

from text.

jekbradbury avatar jekbradbury commented on August 16, 2024

It's always possible for the user to provide a sort_key that's the negative of what they would otherwise provide. Would that be enough to make the default behavior consistent with the RNN API? Should we default to treating sort_keys as implicitly negative? Or provide an additional kwarg for Iterators to reverse their sort order?

from text.

PetrochukM avatar PetrochukM commented on August 16, 2024

@jekbradbury I think the sort_key should remain as it is. Otherwise, it would not be consistent with default sorting behavior.

Maybe add a parameter reverse and have it defaulted to True. That would be consistent with sort and torch.RNN. Like you mentioned!

On another note:
Going to close this issue. Unable to replicate my original bug.

from text.

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.