Struct ParamsBase

Source
pub struct ParamsBase<S = OwnedRepr<f64>, D = Ix2, K = Biased>
where D: Dimension, S: RawData,
{ /* private fields */ }
Expand description

The ParamsBase struct is a generic store for linear parameters. The store mimics the underlying ArrayBase, enabling developers to specify the data repr and dimension. Additionally, the store is parameterized to accept a K type, used to designate the store as either Biased or Unbiased.

Implementations§

Source§

impl<A, S, D, K> ParamsBase<S, D, K>
where D: RemoveAxis, S: RawData<Elem = A>,

Source

pub fn from_elem<Sh>(shape: Sh, elem: A) -> Self
where A: Clone, K: ParamMode, S: DataOwned, Sh: ShapeBuilder<Dim = D>,

Source

pub fn into_biased(self) -> ParamsBase<S, D, Biased>
where A: Default, K: 'static, S: DataOwned,

Source

pub fn into_unbiased(self) -> ParamsBase<S, D, Unbiased>

Source

pub const fn weights(&self) -> &ArrayBase<S, D>

Source

pub fn weights_mut(&mut self) -> &mut ArrayBase<S, D>

Source

pub fn features(&self) -> Features

Source

pub fn in_features(&self) -> usize

Source

pub fn out_features(&self) -> usize

Source

pub fn is_biased(&self) -> bool
where K: 'static,

Returns true if the parameter store is biased; Compares the TypeId of the store with the Biased type.

Source

pub fn new<Sh>(shape: Sh) -> Self
where K: ParamMode, Sh: ShapeBuilder<Dim = D>, A: Default, S: DataOwned,

Source

pub fn ones<Sh>(shape: Sh) -> Self
where K: ParamMode, Sh: ShapeBuilder<Dim = D>, A: Clone + One, S: DataOwned,

Source

pub fn zeros<Sh>(shape: Sh) -> Self
where K: ParamMode, Sh: ShapeBuilder<Dim = D>, A: Clone + Zero, S: DataOwned,

Source

pub fn dim(&self) -> D::Pattern

Return the pattern of the dimension

Source

pub fn ndim(&self) -> usize

Returns rank (ndim) of the dimension

Source

pub fn raw_dim(&self) -> D

Returns the raw dimension D

Source

pub fn shape(&self) -> &[usize]

Returns a reference to the current dimension, as a slice.

Source

pub fn into_owned(self) -> ParamsBase<OwnedRepr<A>, D, K>
where A: Clone, S: Data,

Source

pub fn into_shared(self) -> ParamsBase<OwnedArcRepr<A>, D, K>
where A: Clone, S: DataOwned,

Source

pub fn to_owned(&self) -> ParamsBase<OwnedRepr<A>, D, K>
where A: Clone, S: Data,

Source

pub fn to_shared(&self) -> ParamsBase<OwnedArcRepr<A>, D, K>
where A: Clone, S: DataOwned,

Source

pub fn view(&self) -> ParamsBase<ViewRepr<&A>, D, K>
where A: Clone, S: Data,

Source

pub fn view_mut(&mut self) -> ParamsBase<ViewRepr<&mut A>, D, K>
where A: Clone, S: DataMut,

Source§

impl<A, S, D> ParamsBase<S, D, Biased>
where D: RemoveAxis, S: RawData<Elem = A>,

Source

pub fn biased<Sh>(shape: Sh) -> Self
where A: Default, S: DataOwned, Sh: ShapeBuilder<Dim = D>,

Create a new biased parameter store from the given shape.

Source

pub fn bias(&self) -> &ArrayBase<S, D::Smaller>

Return an unwraped, immutable reference to the bias array.

Source

pub fn bias_mut(&mut self) -> &mut ArrayBase<S, D::Smaller>

Return an unwraped, mutable reference to the bias array.

Source§

impl<A, S, D> ParamsBase<S, D, Unbiased>
where D: Dimension, S: RawData<Elem = A>,

Source

pub fn unbiased<Sh>(shape: Sh) -> Self
where A: Default, S: DataOwned, Sh: ShapeBuilder<Dim = D>,

Create a new unbiased parameter store from the given shape.

Source§

impl<A, S, K> ParamsBase<S, Ix2, K>
where K: 'static, S: RawData<Elem = A>,

Source

pub fn set_node( &mut self, idx: usize, node: (ArrayBase<OwnedRepr<A>, Ix1>, Option<ArrayBase<OwnedRepr<A>, Ix0>>), )
where A: Clone + Default, S: DataMut + DataOwned,

Source§

impl<A, S, D, K> ParamsBase<S, D, K>

Source

pub fn uniform(self) -> LinearParams<A, K, D>
where S: DataOwned,

Source

pub fn uniform_between(self, low: A, high: A) -> LinearParams<A, K, D>
where S: DataOwned,

Source§

impl<A, K, S, D> ParamsBase<S, D, K>
where D: RemoveAxis, S: RawData<Elem = A>,

Source

pub fn activate<F, X, Y>(&mut self, args: &X, f: F) -> Y
where F: for<'a> Fn(&'a Y) -> Y, S: Data<Elem = A>, Self: Predict<X, Output = Y>,

Trait Implementations§

Source§

impl<A, S, D, K> Borrow<ParamsBase<S, D, K>> for Linear<A, K, D, S>
where D: RemoveAxis, S: RawData<Elem = A>,

Source§

fn borrow(&self) -> &ParamsBase<S, D, K>

Immutably borrows from an owned value. Read more
Source§

impl<A, S, D, K> BorrowMut<ParamsBase<S, D, K>> for Linear<A, K, D, S>
where D: RemoveAxis, S: RawData<Elem = A>,

Source§

fn borrow_mut(&mut self) -> &mut ParamsBase<S, D, K>

Mutably borrows from an owned value. Read more
Source§

impl<A, S, D> Clone for ParamsBase<S, D>
where A: Clone, D: RemoveAxis, S: RawDataClone<Elem = A>,

Source§

fn clone(&self) -> Self

Returns a copy 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<A, S, D> Default for ParamsBase<S, D, Biased>
where A: Default, D: Dimension, S: DataOwned<Elem = A>,

Source§

fn default() -> Self

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

impl<A, S, D> Default for ParamsBase<S, D, Unbiased>
where A: Default, D: Dimension, S: DataOwned<Elem = A>,

Source§

fn default() -> Self

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

impl<'a, A, S, D, K> Deserialize<'a> for ParamsBase<S, D, K>
where A: Deserialize<'a>, D: Deserialize<'a> + RemoveAxis, S: DataOwned<Elem = A>, <D as Dimension>::Smaller: Deserialize<'a> + Dimension,

Source§

fn deserialize<Der>(deserializer: Der) -> Result<Self, Der::Error>
where Der: Deserializer<'a>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<A> From<(ArrayBase<OwnedRepr<A>, Dim<[usize; 1]>>, A)> for ParamsBase<OwnedRepr<A>, Ix1, Biased>
where A: Clone,

Source§

fn from((weights, bias): (Array1<A>, A)) -> Self

Converts to this type from the input type.
Source§

impl<A, K> From<(ArrayBase<OwnedRepr<A>, Dim<[usize; 1]>>, Option<A>)> for ParamsBase<OwnedRepr<A>, Ix1, K>
where A: Clone,

Source§

fn from((weights, bias): (Array1<A>, Option<A>)) -> Self

Converts to this type from the input type.
Source§

impl<A, S, D> From<(ArrayBase<S, D>, ArrayBase<S, <D as Dimension>::Smaller>)> for ParamsBase<S, D, Biased>
where D: RemoveAxis, S: RawData<Elem = A>,

Source§

fn from((weights, bias): (ArrayBase<S, D>, ArrayBase<S, D::Smaller>)) -> Self

Converts to this type from the input type.
Source§

impl<A, S, D, K> From<(ArrayBase<S, D>, Option<ArrayBase<S, <D as Dimension>::Smaller>>)> for ParamsBase<S, D, K>
where D: RemoveAxis, S: RawData<Elem = A>,

Source§

fn from( (weights, bias): (ArrayBase<S, D>, Option<ArrayBase<S, D::Smaller>>), ) -> Self

Converts to this type from the input type.
Source§

impl<A, S> FromIterator<(ArrayBase<OwnedRepr<A>, Dim<[usize; 1]>>, Option<ArrayBase<OwnedRepr<A>, Dim<[usize; 0]>>>)> for ParamsBase<S, Ix2>
where A: Clone + Default, S: DataOwned<Elem = A> + DataMut,

Source§

fn from_iter<I: IntoIterator<Item = (Array1<A>, Option<Array0<A>>)>>( nodes: I, ) -> Self

Creates a value from an iterator. Read more
Source§

impl<A, S, D, K> Initialize<A, D> for ParamsBase<S, D, K>
where D: RemoveAxis, K: ParamMode, S: DataOwned<Elem = A>, StandardNormal: Distribution<A>,

Source§

type Data = S

Source§

fn rand<Sh, Dstr>(shape: Sh, distr: Dstr) -> Self
where Sh: ShapeBuilder<Dim = D>, Dstr: Clone + Distribution<A>,

Generate a random array using the given distribution
Source§

fn rand_with<Sh, Ds, R>(shape: Sh, distr: Ds, rng: &mut R) -> Self
where R: Rng + ?Sized, S: DataOwned, Ds: Clone + Distribution<A>, Sh: ShapeBuilder<Dim = D>,

Generate a random array using the given distribution and random number generator
Source§

fn init_rand<Ds>(self, distr: Ds) -> Self
where S: DataOwned, Ds: Clone + Distribution<A>, Self: Sized,

Initialize an array with random values using the given distribution and current shape
Source§

fn init_rand_with<Ds, R>(self, distr: Ds, rng: &mut R) -> Self
where R: Rng + ?Sized, S: DataOwned, Ds: Clone + Distribution<A>,

Initialize an array with random values from the current shape using the given distribution and random number generator
Source§

impl<A, S, D, E> IntoIterator for ParamsBase<S, D, Biased>
where A: Clone, D: Dimension<Smaller = E> + RemoveAxis, S: Data<Elem = A>, E: RemoveAxis,

Source§

type Item = (ArrayBase<OwnedRepr<A>, E>, ArrayBase<OwnedRepr<A>, <E as Dimension>::Smaller>)

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<<ParamsBase<S, D> as IntoIterator>::Item>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<A, S, D, E> IntoIterator for ParamsBase<S, D, Unbiased>
where A: Clone, D: Dimension<Smaller = E> + RemoveAxis, S: Data<Elem = A>, E: RemoveAxis,

Source§

type Item = ArrayBase<OwnedRepr<A>, E>

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<<ParamsBase<S, D, Unbiased> as IntoIterator>::Item>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<A, S, D, K> PartialEq<(ArrayBase<S, D>, ArrayBase<S, <D as Dimension>::Smaller>)> for ParamsBase<S, D, K>
where A: PartialEq, D: RemoveAxis, S: Data<Elem = A>,

Source§

fn eq( &self, (weights, bias): &(ArrayBase<S, D>, ArrayBase<S, D::Smaller>), ) -> 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<A, S, D, K> PartialEq<(ArrayBase<S, D>, Option<ArrayBase<S, <D as Dimension>::Smaller>>)> for ParamsBase<S, D, K>
where A: PartialEq, D: RemoveAxis, S: Data<Elem = A>,

Source§

fn eq( &self, (weights, bias): &(ArrayBase<S, D>, Option<ArrayBase<S, D::Smaller>>), ) -> 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<A, S, D> PartialEq for ParamsBase<S, D>
where A: PartialEq, D: RemoveAxis, S: Data<Elem = A>,

Source§

fn eq(&self, other: &Self) -> 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<'a, A, B, T, S, D, K> Predict<A> for &'a ParamsBase<S, D, K>
where A: Dot<Array<T, D>, Output = B>, B: Add<&'a ArrayBase<S, D::Smaller>, Output = B>, D: RemoveAxis, S: Data<Elem = T>, T: ComplexFloat,

Source§

type Output = B

Source§

fn predict(&self, input: &A) -> Result<Self::Output, PredictError>

Source§

impl<A, B, T, S, D, K> Predict<A> for ParamsBase<S, D, K>
where A: Dot<Array<T, D>, Output = B>, B: for<'a> Add<&'a ArrayBase<S, D::Smaller>, Output = B>, D: RemoveAxis, S: Data<Elem = T>, T: ComplexFloat,

Source§

type Output = B

Source§

fn predict(&self, input: &A) -> Result<Self::Output, PredictError>

Source§

impl<A, S, D, K> Serialize for ParamsBase<S, D, K>
where A: Serialize, D: RemoveAxis + Serialize, S: Data<Elem = A>, <D as Dimension>::Smaller: Dimension + Serialize,

Source§

fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
where Ser: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<A, S, D> Copy for ParamsBase<S, D>
where A: Copy, D: Copy + RemoveAxis, S: Copy + RawDataClone<Elem = A>, <D as Dimension>::Smaller: Copy,

Auto Trait Implementations§

§

impl<S, D, K> Freeze for ParamsBase<S, D, K>
where S: Freeze, D: Freeze, <D as Dimension>::Smaller: Freeze,

§

impl<S, D, K> RefUnwindSafe for ParamsBase<S, D, K>

§

impl<S, D, K> Send for ParamsBase<S, D, K>
where S: Send + Data, K: Send,

§

impl<S, D, K> Sync for ParamsBase<S, D, K>
where S: Sync + Data, K: Sync,

§

impl<S, D, K> Unpin for ParamsBase<S, D, K>
where S: Unpin, D: Unpin, K: Unpin, <D as Dimension>::Smaller: Unpin,

§

impl<S, D, K> UnwindSafe for ParamsBase<S, D, K>

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<X, Y, S> Forward<X> for S
where S: Predict<X, Output = Y>,

Source§

type Output = Y

Source§

fn forward(&self, args: &X) -> <S as Forward<X>>::Output

Source§

impl<I, M, T> ForwardIter<T> for I
where I: IntoIterator<Item = M>, M: Forward<T, Output = T>, T: Clone,

Source§

type Item = M

Source§

fn forward_iter(self, args: &T) -> <M as Forward<T>>::Output

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<K, S> Id<K> for S
where S: Borrow<K>, K: Identifier,

Source§

type Item = S

Source§

fn get(&self) -> &<S as Id<K>>::Item

Source§

impl<U, A, S, D> InitializeExt<A, S, D> for U
where A: Clone, D: Dimension, S: RawData<Elem = A>, U: Initialize<A, D, Data = S>,

Source§

fn bernoulli<Sh>(shape: Sh, p: f64) -> Result<Self, BernoulliError>
where S: DataOwned, Sh: ShapeBuilder<Dim = D>, Bernoulli: Distribution<A>,

Source§

fn lecun_normal<Sh>(shape: Sh, n: usize) -> Self
where A: Float, S: DataOwned, Sh: ShapeBuilder<Dim = D>, StandardNormal: Distribution<A>,

Initialize the object according to the Lecun Initialization scheme. LecunNormal distributions are truncated Normal distributions centered at 0 with a standard deviation equal to the square root of the reciprocal of the number of inputs.
Source§

fn normal<Sh>(shape: Sh, mean: A, std: A) -> Result<Self, Error>
where A: Float, S: DataOwned, Sh: ShapeBuilder<Dim = D>, StandardNormal: Distribution<A>,

Given a shape, mean, and standard deviation generate a new object using the Normal distribution
Source§

fn randc<Sh>(shape: Sh, re: A, im: A) -> Self
where S: DataOwned, Sh: ShapeBuilder<Dim = D>, ComplexDistribution<A>: Distribution<A>,

Source§

fn stdnorm<Sh>(shape: Sh) -> Self
where S: DataOwned, Sh: ShapeBuilder<Dim = D>, StandardNormal: Distribution<A>,

Generate a random array using the StandardNormal distribution
Source§

fn stdnorm_from_seed<Sh>(shape: Sh, seed: u64) -> Self
where S: DataOwned, Sh: ShapeBuilder<Dim = D>, StandardNormal: Distribution<A>,

Generate a random array using the StandardNormal distribution with a given seed
Source§

fn truncnorm<Sh>(shape: Sh, mean: A, std: A) -> Result<Self, Error>
where A: Float, S: DataOwned, Sh: ShapeBuilder<Dim = D>, StandardNormal: Distribution<A>,

Initialize the object using the TruncatedNormal distribution
Source§

fn uniform<Sh>(shape: Sh, dk: A) -> Self
where A: Neg<Output = A> + SampleUniform, S: DataOwned, Sh: ShapeBuilder<Dim = D>, <A as SampleUniform>::Sampler: Clone,

A uniform generator with values between u(-dk, dk)
Source§

fn uniform_from_seed<Sh>(shape: Sh, start: A, stop: A, key: u64) -> Self
where A: SampleUniform, S: DataOwned, Sh: ShapeBuilder<Dim = D>, <A as SampleUniform>::Sampler: Clone,

Source§

fn uniform_along<Sh>(shape: Sh, axis: usize) -> Self
where A: Copy + Float + SampleUniform, S: DataOwned, Sh: ShapeBuilder<Dim = D>, <A as SampleUniform>::Sampler: Clone,

Generate a random array with values between u(-a, a) where a is the reciprocal of the value at the given axis
Source§

fn uniform_between<Sh>(shape: Sh, a: A, b: A) -> Self
where A: SampleUniform, S: DataOwned, Sh: ShapeBuilder<Dim = D>, <A as SampleUniform>::Sampler: Clone,

A uniform generator with values between u(-dk, dk)
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IsBiased for T
where T: 'static,

Source§

fn is_biased(&self) -> bool

Source§

impl<T> IsType for T
where T: 'static,

Source§

fn of<T>() -> bool
where T: 'static,

Source§

fn is<T>(&self) -> bool
where T: 'static,

Source§

impl<T> OfType for T

Source§

fn of<T>() -> bool
where T: 'static, Self: 'static,

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, 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,