Comments (4)
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.
@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.
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_key
s as implicitly negative? Or provide an additional kwarg for Iterator
s to reverse their sort order?
from text.
@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)
- UTF-8 error with testing set of `torchtext.datasets.Multi30k(language_pair=("de", "en"))`. HOT 4
- Torch Text Transform Documentation Mismatch
- The Future of torchtext HOT 1
- BLEU_SCORE weird behaviour
- Fail to import torchtext KeyError: 'SP_DIR' HOT 1
- how to install libtorchtext for cpp project use? please give some operation .thanks
- Unable to download wikitext datasets HOT 4
- AttributeError: module 'torchtext' has no attribute 'legacy'
- # Liste von Namen und Alter personen = [ {"name": "Max", "alter": 30}, {"name": "Anna", "alter": 25}, {"name": "Lisa", "alter": 35} ] # Ausgabe der Liste for person in personen: print("Name:", person["name"]) print("Alter:", person["alter"]) print()
- [Release Blocking] TorchData is too old for PyTorch 2.3 HOT 1
- Remove SpaCy/NLTK as an optional dependency by creating our own tokenizer for a number of languages
- wikitext-2 is not available anymore HOT 2
- Why torchtext needs to reinstall torch
- [RFC] Deprecate/Stop TorchText releases starting with Pytorch release 2.4 HOT 9
- PyTorch 2.4 is not supported by TorchText
- Wikitext-103 URL is down HOT 3
- t5_demo can't retrieve CNNDM from drive.google; how to use local copy?
- Importing Batch TorchText.Legacy versus Torchtext Failures HOT 3
- strange pyd error with no documentation + "OSError: [WinError 127] The specified procedure could not be found" HOT 2
- undefined symbol
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from text.