-
-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support batch-level transformations in Encoding
s
#251
Comments
No issues here with the proposed API. Typically, in FastAI, we have a "batch of images" or a "batch of tabular entries." Similarly, here we have a "batch of sequences." Ultimately, the model will want a "sequence of batches" though, so this transformation needs to happen somewhere. After this transformation, it becomes very hard to access each sample individually, so it must only happen at the end. Even if we do this as a final encoding step, there's the question of how FastAI understands the encoded block. With other data, you can view the individual encoded samples or encoded batch. What will the view look like here? |
Can you explain a bit more what you mean by "sequence of batches" so I can wrap my head around it? |
Yeah, even I didn't get it. Batches don't have to be in a "sequence" to be fed into the model but a batch should have sequences. |
Flux RNNs expect an input format of |
Quite the opposite for Flux as Brian pointed out. Let me add to this in case there is uncertainty about how recurrence is handled in Flux. If you have a recurrent model Batching serves many purposes in ML, but one of them is achieving higher utilization for hardware that supports parallelism. So, in the framework described above, we want The relevant detail here for the issue is that once you have the data in this format, accessing a single sample becomes cumbersome. You have to iterate over TL;DR:
|
Hm, I see the issue and how this doesn't solve it. Of course putting the batchseq into the model is not desirable either. |
Yeah I like this approach better because of the unification. It addresses the concerns about tying |
Yeah, I think the approach Lorenz suggested should be "the way" to achieve this batch-wise encoding. But, where do we encode this? Will this be a part of the initial transformations? Or just before passing the data to the model? |
Adding this kind of first-class support for batches will entail a lot of changes to FastAi.jl internals, e.g. applying encode to batches and not individual samples, but should ultimately reduce the amount of code. Until we find time to implement those changes, though, I would continue with the current method of doing the sequencing. |
Sometimes encodings need to be able to take into account batch information, as in a sequence learning task where samples in a batch should be padded to the length of the longest sequence.
Currently, all
Encoding
s transform individual samples, which is great for simplicity and composability, but doesn't allow implementing these batch-level transformations.A usage of encodings in basically every training loop is
taskdataloaders
which will always give batches of encoded data. We could have this use a new functionencodebatch(encoding, context, block, samples)
that transforms multiple samples at a time. This would operate on vectors of samples, not a collated batch, since not all kinds of data can be collated (e.g. different-sized images).By default, it would simply delegate to the single-sample
encode
function:But it could be overwritten by individual encodings:
Tagging relevant parties @Chandu-4444 @darsnack @ToucheSir for discussion.
The text was updated successfully, but these errors were encountered: