pub trait Initialize<A, D>where
D: Dimension,{
type Data: RawData<Elem = A>;
// Required methods
fn rand<Sh, Ds>(shape: Sh, distr: Ds) -> Self
where Ds: Clone + Distribution<A>,
Sh: ShapeBuilder<Dim = D>,
Self::Data: DataOwned;
fn rand_with<Sh, Ds, R>(shape: Sh, distr: Ds, rng: &mut R) -> Self
where R: Rng + ?Sized,
Ds: Clone + Distribution<A>,
Sh: ShapeBuilder<Dim = D>,
Self::Data: DataOwned;
fn init_rand<Ds>(self, distr: Ds) -> Self
where Ds: Clone + Distribution<A>,
Self: Sized,
Self::Data: DataOwned;
fn init_rand_with<Ds, R>(self, distr: Ds, rng: &mut R) -> Self
where R: Rng + ?Sized,
Ds: Clone + Distribution<A>,
Self::Data: DataOwned;
}Expand description
This trait provides the base methods required for initializing an ndarray with random values. Initialize is similar to RandomExt, however, it focuses on flexibility while implementing additional features geared towards machine-learning models; such as lecun_normal initialization.
Required Associated Types§
Required Methods§
Sourcefn 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
Sourcefn rand_with<Sh, Ds, R>(shape: Sh, distr: Ds, rng: &mut R) -> Selfwhere
R: Rng + ?Sized,
Ds: Clone + Distribution<A>,
Sh: ShapeBuilder<Dim = D>,
Self::Data: DataOwned,
fn rand_with<Sh, Ds, R>(shape: Sh, distr: Ds, rng: &mut R) -> Selfwhere
R: Rng + ?Sized,
Ds: Clone + Distribution<A>,
Sh: ShapeBuilder<Dim = D>,
Self::Data: DataOwned,
Generate a random array using the given distribution and random number generator
Sourcefn 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
Sourcefn 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
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.