Trait Initialize

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

Source

type Data: RawData<Elem = A>

Required Methods§

Source

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

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, Ds: Clone + Distribution<A>, Sh: ShapeBuilder<Dim = D>, Self::Data: DataOwned,

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

Source

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

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, Ds: Clone + Distribution<A>, Self::Data: DataOwned,

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.

Implementations on Foreign Types§

Source§

impl<A, S, D> Initialize<A, D> for ArrayBase<S, D>
where D: Dimension, S: RawData<Elem = A>, ArrayBase<S, D>: RandomExt<S, A, D>,

Source§

type Data = S

Source§

fn rand<Sh, Ds>(shape: Sh, distr: Ds) -> ArrayBase<S, D>
where S: DataOwned, Ds: Clone + Distribution<S::Elem>, Sh: ShapeBuilder<Dim = D>,

Source§

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

Source§

fn init_rand<Ds>(self, distr: Ds) -> ArrayBase<S, D>
where S: DataOwned, Ds: Clone + Distribution<S::Elem>,

Source§

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

Implementors§