BatchWrapper
Before we delve into BatchWrapper, let me tell you what the problem with batch objects is. Our batch iterator returns a custom datatype, torchtext.data.Batch. This has a similar to multiple example.Example. This returns with a batch of data from each field as attributes. This custom datatype makes code reuse difficult since, each time the column names change, we need to modify the code. This also makes torchtext hard to use with other libraries such as torchsample and fastai.
So, how do we solve this?
We will convert the batch into a tuple in the form (x, y). x is the input to the model and y is the target – or, more conventionally, x is the independent variable while y is the dependent variable. One way to think about this ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access