Skip to main content

Space

Struct Space 

Source
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

Source

pub fn new() -> Self

Nothing to search yet.

Source

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.

Source

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");
Source

pub fn dimensions(&self) -> &[(String, Dimension)]

The knobs, in declaration order.

Source

pub fn len(&self) -> usize

How many knobs there are.

Source

pub fn is_empty(&self) -> bool

Whether there is nothing to search.

Trait Implementations§

Source§

impl Clone for Space

Source§

fn clone(&self) -> Space

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Space

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Space

Source§

fn default() -> Space

Returns the “default value” for a type. Read more
Source§

impl Display for Space

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Space

Source§

fn eq(&self, other: &Space) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.