pub struct ArchSampler { /* private fields */ }Expand description
Samples and mutates architectures within an ArchSearchSpace.
Implementations§
Source§impl ArchSampler
impl ArchSampler
Sourcepub fn new(space: ArchSearchSpace, seed: u64) -> Self
pub fn new(space: ArchSearchSpace, seed: u64) -> Self
Create a new sampler for the given search space, seeded for reproducibility.
Sourcepub fn random_architecture(&mut self) -> TrainResult<Architecture>
pub fn random_architecture(&mut self) -> TrainResult<Architecture>
Sample a uniformly random architecture within the search space.
Depth is drawn uniformly from [min_depth, max_depth]. Each layer’s
op, width, and activation are drawn independently and uniformly from
their respective option lists.
Sourcepub fn mutate(&mut self, arch: &Architecture) -> TrainResult<Architecture>
pub fn mutate(&mut self, arch: &Architecture) -> TrainResult<Architecture>
Mutate one aspect of arch at random, returning a new valid architecture.
Four mutations are selected uniformly at random:
| Index | Mutation |
|---|---|
| 0 | Change a random layer’s op |
| 1 | Change a random layer’s width |
| 2 | Change a random layer’s activation |
| 3 | Add a layer (if depth < max_depth) or remove one (if depth > min_depth); if neither is possible, fall back to changing op |
Sourcepub fn gen_range_usize(&mut self, lower: usize, upper: usize) -> usize
pub fn gen_range_usize(&mut self, lower: usize, upper: usize) -> usize
Generate a uniformly random usize in [lower, upper).
Used by super::RegularizedEvolution to share the sampler’s RNG for
tournament index shuffling. Returns lower when upper <= lower.
Auto Trait Implementations§
impl Freeze for ArchSampler
impl RefUnwindSafe for ArchSampler
impl Send for ArchSampler
impl Sync for ArchSampler
impl Unpin for ArchSampler
impl UnsafeUnpin for ArchSampler
impl UnwindSafe for ArchSampler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more