-
Notifications
You must be signed in to change notification settings - Fork 0
Composite Sampler #250
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
Composite Sampler #250
Changes from 1 commit
1d4cbaf
8dfbc8a
3535b0f
e279769
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ | |
) | ||
from confopt.oneshot.archsampler import ( | ||
BaseSampler, | ||
CompositeSampler, | ||
DARTSSampler, | ||
DRNASSampler, | ||
GDASSampler, | ||
|
@@ -374,17 +375,36 @@ def _set_sampler( | |
config: dict, | ||
) -> None: | ||
arch_params = self.search_space.arch_parameters | ||
self.sampler: BaseSampler | None = None | ||
if sampler == SamplerType.DARTS: | ||
self.sampler = DARTSSampler(**config, arch_parameters=arch_params) | ||
elif sampler == SamplerType.DRNAS: | ||
self.sampler = DRNASSampler(**config, arch_parameters=arch_params) | ||
elif sampler == SamplerType.GDAS: | ||
self.sampler = GDASSampler(**config, arch_parameters=arch_params) | ||
elif sampler == SamplerType.SNAS: | ||
self.sampler = SNASSampler(**config, arch_parameters=arch_params) | ||
elif sampler == SamplerType.REINMAX: | ||
self.sampler = ReinMaxSampler(**config, arch_parameters=arch_params) | ||
self.sampler: BaseSampler | CompositeSampler | None = None | ||
|
||
def _get_sampler_class(sampler: SamplerType) -> Callable: | ||
if sampler == SamplerType.DARTS: | ||
return DARTSSampler | ||
if sampler == SamplerType.DRNAS: | ||
return DRNASSampler | ||
if sampler == SamplerType.GDAS: | ||
return GDASSampler | ||
if sampler == SamplerType.SNAS: | ||
return SNASSampler | ||
if sampler == SamplerType.REINMAX: | ||
return ReinMaxSampler | ||
|
||
raise ValueError(f"Illegal sampler {sampler} provided") | ||
|
||
if sampler == SamplerType.COMPOSITE: | ||
sub_samplers: list[BaseSampler] = [] | ||
for _, sampler_config in config.items(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I'm not mistaken, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think with python versions 3.7 and above, the insertion order is preserved |
||
sampler_type = sampler_config["sampler_type"] | ||
del sampler_config["sampler_type"] | ||
sampler_component = _get_sampler_class(sampler_type)( | ||
**sampler_config, arch_parameters=arch_params | ||
) | ||
sub_samplers.append(sampler_component) | ||
self.sampler = CompositeSampler(sub_samplers, arch_parameters=arch_params) | ||
else: | ||
self.sampler = _get_sampler_class(sampler)( | ||
**config, arch_parameters=arch_params | ||
) | ||
|
||
def _set_perturbator( | ||
self, | ||
|
Uh oh!
There was an error while loading. Please reload this page.