pub struct Linear<A = f64, K = Biased, D = Ix2, S = OwnedRepr<A>>{ /* private fields */ }Expand description
An implementation of a linear model.
In an effort to streamline the api, the Linear model relies upon a ParamMode type (Biased or Unbiased) which enables the model to automatically determine whether or not to include a bias term. Doing so allows the model to inherit several methods familar to the underlying ndarray crate.
Implementations§
Source§impl<A, S, D, K> Linear<A, K, D, S>
impl<A, S, D, K> Linear<A, K, D, S>
pub fn new<Sh>(shape: Sh) -> Self
pub fn ones<Sh>(shape: Sh) -> Self
pub fn zeros<Sh>(shape: Sh) -> Self
pub fn from_config(config: Config<K, D>) -> Self
pub fn from_layout(layout: Layout<D>) -> Self
pub fn from_params(params: ParamsBase<S, D, K>) -> Self
Sourcepub fn activate<X, Y, F>(&self, args: &X, func: F) -> Result<Y>
pub fn activate<X, Y, F>(&self, args: &X, func: F) -> Result<Y>
Applies an activcation function onto the prediction of the model.
pub const fn config(&self) -> &Config<K, D>
pub fn weights(&self) -> &ArrayBase<S, D>
pub fn weights_mut(&mut self) -> &mut ArrayBase<S, D>
pub const fn params(&self) -> &ParamsBase<S, D, K>
pub fn params_mut(&mut self) -> &mut ParamsBase<S, D, K>
pub fn into_biased(self) -> Linear<A, Biased, D, S>
pub fn into_unbiased(self) -> Linear<A, Unbiased, D, S>
pub fn is_biased(&self) -> boolwhere
K: 'static,
pub fn with_params<E>(self, params: LinearParams<A, K, E>) -> Linear<A, K, E>where
E: RemoveAxis,
pub fn with_name(self, name: impl ToString) -> Self
Source§impl<A, S, D> Linear<A, Unbiased, D, S>where
D: RemoveAxis,
S: RawData<Elem = A>,
impl<A, S, D> Linear<A, Unbiased, D, S>where
D: RemoveAxis,
S: RawData<Elem = A>,
Source§impl<A, S, D, K> Linear<A, K, D, S>where
A: Clone + Float,
D: RemoveAxis,
K: ParamMode,
S: DataOwned<Elem = A>,
StandardNormal: Distribution<A>,
impl<A, S, D, K> Linear<A, K, D, S>where
A: Clone + Float,
D: RemoveAxis,
K: ParamMode,
S: DataOwned<Elem = A>,
StandardNormal: Distribution<A>,
Trait Implementations§
Source§impl<A, S, D, K> Borrow<Config<K, D>> for Linear<A, K, D, S>where
D: RemoveAxis,
S: RawData<Elem = A>,
impl<A, S, D, K> Borrow<Config<K, D>> for Linear<A, K, D, S>where
D: RemoveAxis,
S: RawData<Elem = A>,
Source§impl<A, S, D, K> Borrow<ParamsBase<S, D, K>> for Linear<A, K, D, S>where
D: RemoveAxis,
S: RawData<Elem = A>,
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>
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>,
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>
fn borrow_mut(&mut self) -> &mut ParamsBase<S, D, K>
Mutably borrows from an owned value. Read more
Source§impl<A, S, D, K> Initialize<A, D> for Linear<A, K, D, S>
impl<A, S, D, K> Initialize<A, D> for Linear<A, K, D, S>
type Data = OwnedRepr<A>
Source§fn rand<Sh, Ds>(shape: Sh, distr: Ds) -> Self
fn rand<Sh, Ds>(shape: Sh, distr: Ds) -> Self
Generate a random array using the given distribution
Source§fn rand_with<Sh, Ds, R>(shape: Sh, distr: Ds, rng: &mut R) -> Self
fn rand_with<Sh, Ds, R>(shape: Sh, distr: Ds, rng: &mut R) -> Self
Generate a random array using the given distribution and random number generator
Source§fn init_rand<Ds>(self, distr: Ds) -> Self
fn init_rand<Ds>(self, distr: Ds) -> Self
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
fn init_rand_with<Ds, R>(self, distr: Ds, rng: &mut R) -> Self
Initialize an array with random values from the current shape using the given distribution and random number generator
Source§impl<A, K, D> Module for Linear<A, K, D>where
D: RemoveAxis,
impl<A, K, D> Module for Linear<A, K, D>where
D: RemoveAxis,
Auto Trait Implementations§
impl<A, K, D, S> Freeze for Linear<A, K, D, S>
impl<A, K, D, S> RefUnwindSafe for Linear<A, K, D, S>where
D: RefUnwindSafe,
K: RefUnwindSafe,
S: RefUnwindSafe,
<D as Dimension>::Smaller: RefUnwindSafe,
A: RefUnwindSafe,
impl<A, K, D, S> Send for Linear<A, K, D, S>
impl<A, K, D, S> Sync for Linear<A, K, D, S>
impl<A, K, D, S> Unpin for Linear<A, K, D, S>
impl<A, K, D, S> UnwindSafe for Linear<A, K, D, S>where
D: UnwindSafe,
K: UnwindSafe,
S: UnwindSafe,
<D as Dimension>::Smaller: UnwindSafe,
A: RefUnwindSafe,
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
Source§impl<K, S> Id<K> for Swhere
S: Borrow<K>,
K: Identifier,
impl<K, S> Id<K> for Swhere
S: Borrow<K>,
K: Identifier,
Source§impl<U, A, S, D> InitializeExt<A, S, D> for U
impl<U, A, S, D> InitializeExt<A, S, D> for U
fn bernoulli<Sh>(shape: Sh, p: f64) -> Result<Self, BernoulliError>
Source§fn lecun_normal<Sh>(shape: Sh, n: usize) -> Self
fn lecun_normal<Sh>(shape: Sh, n: usize) -> Self
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>
fn normal<Sh>(shape: Sh, mean: A, std: A) -> Result<Self, Error>
Given a shape, mean, and standard deviation generate a new object using the Normal distribution
fn randc<Sh>(shape: Sh, re: A, im: A) -> Self
Source§fn stdnorm<Sh>(shape: Sh) -> Self
fn stdnorm<Sh>(shape: Sh) -> Self
Generate a random array using the StandardNormal distribution
Source§fn stdnorm_from_seed<Sh>(shape: Sh, seed: u64) -> Self
fn stdnorm_from_seed<Sh>(shape: Sh, seed: u64) -> Self
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>
fn truncnorm<Sh>(shape: Sh, mean: A, std: A) -> Result<Self, Error>
Initialize the object using the TruncatedNormal distribution
Source§fn uniform<Sh>(shape: Sh, dk: A) -> Selfwhere
A: Neg<Output = A> + SampleUniform,
S: DataOwned,
Sh: ShapeBuilder<Dim = D>,
<A as SampleUniform>::Sampler: Clone,
fn uniform<Sh>(shape: Sh, dk: A) -> Selfwhere
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)
fn uniform_from_seed<Sh>(shape: Sh, start: A, stop: A, key: u64) -> Selfwhere
A: SampleUniform,
S: DataOwned,
Sh: ShapeBuilder<Dim = D>,
<A as SampleUniform>::Sampler: Clone,
Source§fn uniform_along<Sh>(shape: Sh, axis: usize) -> Selfwhere
A: Copy + Float + SampleUniform,
S: DataOwned,
Sh: ShapeBuilder<Dim = D>,
<A as SampleUniform>::Sampler: Clone,
fn uniform_along<Sh>(shape: Sh, axis: usize) -> Selfwhere
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) -> Selfwhere
A: SampleUniform,
S: DataOwned,
Sh: ShapeBuilder<Dim = D>,
<A as SampleUniform>::Sampler: Clone,
fn uniform_between<Sh>(shape: Sh, a: A, b: A) -> Selfwhere
A: SampleUniform,
S: DataOwned,
Sh: ShapeBuilder<Dim = D>,
<A as SampleUniform>::Sampler: Clone,
A uniform generator with values between u(-dk, dk)