-
Notifications
You must be signed in to change notification settings - Fork 413
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
Unify algorithms part 2: mixup, cutmix, label smoothing #658
Conversation
I like where this is going! Agreed on |
I think this behavior in mixup_batch is a holdover from the old repo that got ported over. I don't think the original reason for doing that exists in composer, and not returning the permutation should be fine. It makes the functional interface feel a lot cleaner to me. However, two possible reasons to return permutations: 1) If someone wants to do further analysis/debugging of what mixup_batch and cutmix_batch are doing to the inputs, this could be handy, and 2) returning the permutation makes it possible to use the loss interpolation trick people often do to use mixup and cutmix with index labels after using mixup_batch and cutmix_batch if they so choose. |
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.
I noticed two instances of significant test setup code to create the model and dataloaders. Are those needed, given that some of these are auto-loaded in https://github.com/mosaicml/composer/blob/dev/docs/source/doctest_fixtures.py ?
Also -- update yamls? |
The algorithm yamls? The label_smoothing one is updated, but cutmix and mixup fortunately don't have to change anything since they only use |
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.
LGTM
Addresses #343, or at least well enough for present purposes. Changes: * colout.py: rename X -> input * cutout.py: rename X -> input, n_holes -> num_holes, make cutout_batch length fractional-only to match cutmix.py (see discussion in #658) * account for n_holes -> num_holes rename, as well as no int lengths in: * test_cutout.py * algorithms/hparams.py * yamls/algorithms/cutout.yaml * test_algorithm_registry.py * test_load.py * test_trainer.py * examples/adding_custom_models.py * notebooks/medical_image_segmentation_composer.ipynb * progressive_resizing.py: rename X -> input, y -> target * selective_backprop.py: rename X -> input, y -> target Minor docstring cleanup: - augmix_image now has correct input type shown in docstring - randaugment_image now has correct input type shown in docstring
Follow-up to #524 to continue addressing #343. This is mostly cleaning up the docs to be consistent across methods + match the code's behavior, fixing the doctests, and modifying the docstrings in accordance with some slight API changes (mostly param renaming). These changes are:
Mixup:
n_classes
->num_classes
inmixup_batch
, for consitency with torch + rest of composer rather than sklearn.interpolation_lambda
->mixing
inmixup_batch
x
->input
inmixup_batch
for consistency with torchy
->target
inmixup_batch
for consistency with torchCutmix:
n_classes
->num_classes
againX
->input
incutmix_batch
for consistency with torchy
->target
incutmix_batch
for consistency with torchcutmix_lambda
->length
incutmix_batch
, matchingcutout
'slength
argument. As part of this change, I also added changed the logic to 1) correctly compute the internalcutmix_lambda
whenbbox
is provided, and 2) throw if both length and bbox are provided.cutmix_batch
now returns the permutation it used for consistency withmixup_batch
. @coryMosaicML , do we need to return these? We apparently didn't here, but seemingly did inmixup_batch
?Label smoothing:
alpha
->interpolation
insmooth_labels
and algorithmtargets
->target
insmooth_labels
for consistency with torchParts I'm not sure about (updated after slack discussion):
alpha
,length
/cutmix_lambda
, andbbox
). Right nowalpha
is just ignored if others are provided, while the other two now raise aValueError
if both are notNone
. Seems like the least bad way to do this, but a little inconsistent. Maybe we could removebbox
as a parameter?NOTE: need to fix jenkins error + double-check docstring output in the docs, but this is ready for feedback, esp regarding the API questions above.