WIP Allowing for grouped (random) transformations of tensors/tensor-like objects [proof-of-concept] #4267
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implements a POC solution to #1406 (+ #9). Some aspects are similar to #1315.
I propose a GroupTransform class that can take a tuple of inputs, and applied the same transformation to each.
In between two queries of GroupTransform, the random transformations are 'frozen' (i.e. their random parameters are stored as attributes so that they can be re-used as much as needed) and the same transform is applied to each input. This ensures that all the transformations match exactly. When GroupTransform is done, it resets the state of the transformations that are provided to it.
e.g.
The
reset_auto=False
keyword of the transforms basically means that those objects won't be responsible of resetting their state after applying a transform. This responsibility is taken bytransforms.GroupTransform
(if its ownreset_auto
is set toTrue
).## Advantages
GroupTransform
will need to care aboutreset_auto
.Objects of probable contention
Transform
class that inherits fromnn.Module
, and all transforms are now subclasses of it. This may not be ideal and it is totally open to discussion.get_params
methods, that were static, have now lost that attribute (but one can override the default behaviour which is to take the stored parameters by providing other kwargs).TODOs:
reset_auto
attribute, that ensures that random transformations are applied similarly to each input. One could think of a way to set this attribute value after creating the object using a.reset_auto_(mode=True)
method, but for now I feel that this isn't a priority, though it might make things easier to code in the future.