-
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
Refactor transformations by extracting probabilities to get_params() method #3098
Conversation
Hi, Thanks for the PR! I've just made a comment in #3065 (comment) which explains my reasoning behind |
Hi, it seems that the discussion in that thread is still ongoing. Do we want to merge it as it is, i.e leave Thanks! |
@kondela I wonder if you don't mind to finish the 2 remaining methods so that this PR is complete. I have also a bunch of operators that are pending to be merged and use the specific idiom, so if we decide to return a boolean instead of a weight, I can fix yours and mine in the same PR. I don't really have a preference, let me know. :) |
Hey @datumbox I refactored the last two transformations, please see if its okay. I was hoping for a hint since as I said in #3098 (comment) that these two transformations are different. |
Hmm, I just saw that you edited your original message. You are right, let us get back to you on this one. |
Ok, let me know :). I will wait with fixing the failing tests. |
@kondela FYI we have not forgotten about this. It's just unclear right now which path we are going to take. Note that we recently merged PR #3123 which adds more transforms. Originally I took the approach of your PR for structuring the random params but I rolled it back (see #3123 (comment)) until we are certain on how to handle this. |
Fixes: #3066
Transformations that need to be refactored since they call
torch.rand(1)
inforward()
:Not sure how to handle the last two as they already have
get_params()
method define and the probability needs to be drawn beforeget_params()
is called, for exampleRandomPerspective()
:vision/torchvision/transforms/transforms.py
Lines 708 to 711 in 7f1a05a