-
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
support random seed for RA sampler #5053
Conversation
💊 CI failures summary and remediationsAs of commit 17ac681 (more details on the Dr. CI page):
🕵️ 1 new failure recognized by patternsThe following CI failures do not appear to be due to upstream breakages:
|
@@ -9,7 +9,7 @@ | |||
import torchvision | |||
import transforms | |||
import utils | |||
from references.classification.sampler import RASampler | |||
from sampler import RASampler |
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.
Good catch, if this PR is not merged could you please bring this separately?
@@ -15,7 +15,7 @@ class RASampler(torch.utils.data.Sampler): | |||
https://github.com/facebookresearch/deit/blob/main/samplers.py | |||
""" | |||
|
|||
def __init__(self, dataset, num_replicas=None, rank=None, shuffle=True): | |||
def __init__(self, dataset, num_replicas=None, rank=None, shuffle=True, seed=0): |
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 agree this might be useful but it's also a paradigm we don't do on TorchVision. Don't get me wrong, this approach is popular with other libraries it's just that setting seeds on constructors is something we don't typically do.
@fmassa thoughts?
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.
@datumbox The RA sampler is modified from torch.utils.data.DistributedSampler which also has a parameter seed
. The default value of seed
is 0, so it does not affect the behavior of RA samper if users don't explicitly set a seed.
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.
Fair enough. Since DistributedSampler supports it we can also have it.
@@ -15,7 +15,7 @@ class RASampler(torch.utils.data.Sampler): | |||
https://github.com/facebookresearch/deit/blob/main/samplers.py | |||
""" | |||
|
|||
def __init__(self, dataset, num_replicas=None, rank=None, shuffle=True): | |||
def __init__(self, dataset, num_replicas=None, rank=None, shuffle=True, seed=0): |
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.
Fair enough. Since DistributedSampler supports it we can also have it.
Summary: * support random seed used to shuffle the sampler * fix bug for RA samper Reviewed By: fmassa Differential Revision: D33185002 fbshipit-source-id: ed0461edabbeb495923e76d7d5ff59a8e85f422e Co-authored-by: Vasilis Vryniotis <[email protected]>
This pr is about #5051
Two modification:
cc @datumbox