-
Notifications
You must be signed in to change notification settings - Fork 629
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
Simplify AutoAugment graph #4751
Conversation
Signed-off-by: Kamil Tokarski <[email protected]>
Signed-off-by: Kamil Tokarski <[email protected]>
Signed-off-by: Kamil Tokarski <[email protected]>
self._random_sign = random_sign | ||
self._signed_magnitude_idx = signed_magnitude_idx | ||
|
||
def __getitem__(self, idx: int): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This enables the signed_bin(mutli_stage_bin)[stage_idx]
.
!build |
CI MESSAGE: [7762008]: BUILD STARTED |
CI MESSAGE: [7762008]: BUILD PASSED |
The output is a tuple of matrix `m` and per stage operators augmentations list `augments`, | ||
such that for policy `sub_policy_idx` as the `stage_idx`-ith operation in a sequence, the | ||
`augments[stage_idx][m[sub_policy_idx][stage_idx]]` operator should be called. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I may try to expand the comment:
The output is a tuple of matrix `m` and per stage operators augmentations list `augments`, | |
such that for policy `sub_policy_idx` as the `stage_idx`-ith operation in a sequence, the | |
`augments[stage_idx][m[sub_policy_idx][stage_idx]]` operator should be called. | |
The output is a tuple `(m, augments)`, where `augments` is a list of augmentations to be | |
used for given stage - each entry contains the reduced list of unique augmentations to be | |
used for that stage. | |
The `m` matrix contains the mapping from the original sub_policy_id, to the index within the | |
reduced list, for every stage.T | |
That is for policy `sub_policy_idx` as the `stage_idx`-ith operation in a sequence, the | |
`augments[stage_idx][m[sub_policy_idx][stage_idx]]` operator should be called. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'll merge this one, revase the #4753 and expand the comment there.
for stage_id in range(max_policy_len): | ||
magnitude_bin = magnitude_bins[stage_id] | ||
if use_signed_magnitudes: | ||
magnitude_bin = signed_bin(magnitude_bin) | ||
if should_run[stage_id] < run_probabilities[stage_id]: | ||
op_kwargs = dict(sample=sample, magnitude_bin=magnitude_bin, | ||
op_kwargs = dict(sample=sample, magnitude_bin=magnitude_bins[stage_id], | ||
num_magnitude_bins=policy.num_magnitude_bins, **kwargs) | ||
sample = _pretty_select(augmentations, aug_ids[stage_id], op_kwargs, | ||
sample = _pretty_select(augmentations[stage_id], aug_ids[stage_id], op_kwargs, | ||
auto_aug_name='apply_auto_augment', | ||
ref_suite_name='get_image_net_policy') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, this is so cool ;)
Category:
Refactoring (Redesign of existing code that doesn't affect functionality
Description:
This PR combines a couple of improvements to AutoAugment processing graph.
select
operation.For example, the default v0 policy uses 25 sub-policies, each sub-policy is a sequence of (at most) 2 augmentations. Even though there are 25 sub-policies, there are only 11 unique augmentations present in those sub-polcies. DALI already splits the computation only in 11 parts. However, it can be further improved if the operators used in given stages of sub-policies form even smaller groups. In case of the default v0 policy, it is 8 vs 11.
In other words, when the comutation is split to apply the "i-th" augmentation in a sequence according to selected sub-polciy, there is no need to take into account all augmentations present in all sub-polcies, but only the augmentations at the i-th position in all sub-policies.
signed_bin
helper that handles random negation of magnitudes can now accept additional shape parameter. With that, if you have a multiple random augmentations to apply in a sequence, you can generate the random signs of magnitudes once for all stages, rather than do it for every stage separately.Additional information:
Affected modules and functionalities:
AutoAugment (points 1., 2.), RandAugment (point 2.).
Key points relevant for the review:
Tests:
Checklist
Documentation
DALI team only
Requirements
REQ IDs: N/A
JIRA TASK: DALI-3357