pub struct Space { /* private fields */ }Expand description
The knobs, in the order they were declared.
use somatize_study::{Dimension, Space};
let space = Space::new()
.with("lr", Dimension::Real { low: 1e-5, high: 1e-1, log: true })?
.with("batch", Dimension::Int { low: 16, high: 128 })?
.with("optimizer", Dimension::Choice(vec!["adam".into(), "sgd".into()]))?;
assert_eq!(space.len(), 3);Implementations§
Source§impl Space
impl Space
Sourcepub fn with(
self,
name: impl Into<String>,
dimension: Dimension,
) -> Result<Self, SpaceError>
pub fn with( self, name: impl Into<String>, dimension: Dimension, ) -> Result<Self, SpaceError>
One more knob. The name has to be new, and what it may be has to be
something: an empty Choice or a range the wrong way round is refused
here, where it was written, and not as a search that quietly only
ever tried one value.
Sourcepub fn read(&self, said: &str) -> Result<Point, ReadError>
pub fn read(&self, said: &str) -> Result<Point, ReadError>
The point that text names, read against these knobs.
The other half of Point’s Display, and it needs the space: batch=64
on its own does not say whether 64 is a whole number or a
Choice spelt "64". This is what makes a study’s
history come back in one scan and no fetches.
Every knob has to be there and nothing else may be: a record written against another space is a different study.
use somatize_study::{Dimension, Space};
let space = Space::new()
.with("lr", Dimension::Real { low: 1e-5, high: 1e-1, log: true })?
.with("opt", Dimension::Choice(vec!["adam".into(), "sgd".into()]))?;
let point = space.read("lr=0.001,opt=adam")?;
assert_eq!(point.to_string(), "lr=0.001,opt=adam");Sourcepub fn dimensions(&self) -> &[(String, Dimension)]
pub fn dimensions(&self) -> &[(String, Dimension)]
The knobs, in declaration order.
Trait Implementations§
impl StructuralPartialEq for Space
Auto Trait Implementations§
impl Freeze for Space
impl RefUnwindSafe for Space
impl Send for Space
impl Sync for Space
impl Unpin for Space
impl UnsafeUnpin for Space
impl UnwindSafe for Space
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