-
Notifications
You must be signed in to change notification settings - Fork 7k
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
expand has_any and has_all to also accept check callables #6447
Conversation
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.
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. I've added a few optional comments above, I haven't thoroughly checked it as I am in between meetings. Feel free to ignore.
flat_sample, _ = tree_flatten(sample) | ||
return not bool(set(types) - set([type(obj) for obj in flat_sample])) | ||
for type_or_check in types_or_checks: |
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.
They are asymmetric because the behavior we want for has_any
is any(any(...))
and for has_all
is any(all(...))
. If has_all
would be all(all(...))
they would be symmetric.
…6447) Summary: * expand has_any and has_all to also accept check callables * add test and fix has_all * add support for simple tensor images to CutMix, MixUp and RandomIoUCrop * remove TODO * remove pythonic syntax sugar * simplify * use concreate examples in test rather than abstract ones * simplify further Reviewed By: datumbox Differential Revision: D39013675 fbshipit-source-id: 6cd68d471b7cf94192284cdf7948c87ed570e6af
This is useful if the type checking involves more than plain types. A common example is to check for an image in the sample which is done with the types
features.Image
andPIL.Image.Image
as well as the check functionis_simple_tensor
. With this PR, we can pass all three tohas_any
andhas_all
:This PR also uses this new idiom to add support for simple tensors to
CutMix
andMixUp
as well asRandomIoUCrop
as discussed in #6401 (comment).