pub trait Initialize<S, D>: Sized{
Show 15 methods
    // Required methods
    fn rand<Sh, Ds>(shape: Sh, distr: Ds) -> Self
       where Ds: Distribution<<S as RawData>::Elem>,
             Sh: ShapeBuilder<Dim = D>,
             S: DataOwned;
    fn rand_with<Sh, Ds, R>(shape: Sh, distr: Ds, rng: &mut R) -> Self
       where R: RngCore + ?Sized,
             Ds: Distribution<<S as RawData>::Elem>,
             Sh: ShapeBuilder<Dim = D>,
             S: DataOwned;
    // Provided methods
    fn bernoulli<Sh>(shape: Sh, p: f64) -> Result<Self, BernoulliError>
       where Bernoulli: Distribution<<S as RawData>::Elem>,
             S: DataOwned,
             Sh: ShapeBuilder<Dim = D> { ... }
    fn glorot_normal<Sh>(shape: Sh) -> Self
       where Sh: ShapeBuilder<Dim = D>,
             StandardNormal: Distribution<<S as RawData>::Elem>,
             S: DataOwned,
             <S as RawData>::Elem: Float + FromPrimitive { ... }
    fn glorot_uniform<Sh>(shape: Sh) -> Result<Self, InitError>
       where S: DataOwned,
             Sh: ShapeBuilder<Dim = D>,
             <S as RawData>::Elem: Float + FromPrimitive + SampleUniform,
             <<S as RawData>::Elem as SampleUniform>::Sampler: Clone { ... }
    fn lecun_normal<Sh>(shape: Sh) -> Self
       where StandardNormal: Distribution<<S as RawData>::Elem>,
             S: DataOwned,
             Sh: ShapeBuilder<Dim = D>,
             <S as RawData>::Elem: Float { ... }
    fn normal<Sh>(
        shape: Sh,
        mean: <S as RawData>::Elem,
        std: <S as RawData>::Elem,
    ) -> Result<Self, Error>
       where StandardNormal: Distribution<<S as RawData>::Elem>,
             S: DataOwned,
             Sh: ShapeBuilder<Dim = D>,
             <S as RawData>::Elem: Float { ... }
    fn randc<Sh>(
        shape: Sh,
        re: <S as RawData>::Elem,
        im: <S as RawData>::Elem,
    ) -> Self
       where S: DataOwned,
             Sh: ShapeBuilder<Dim = D>,
             ComplexDistribution<<S as RawData>::Elem>: Distribution<<S as RawData>::Elem> { ... }
    fn stdnorm<Sh>(shape: Sh) -> Self
       where StandardNormal: Distribution<<S as RawData>::Elem>,
             S: DataOwned,
             Sh: ShapeBuilder<Dim = D> { ... }
    fn stdnorm_from_seed<Sh>(shape: Sh, seed: u64) -> Self
       where StandardNormal: Distribution<<S as RawData>::Elem>,
             S: DataOwned,
             Sh: ShapeBuilder<Dim = D> { ... }
    fn truncnorm<Sh>(
        shape: Sh,
        mean: <S as RawData>::Elem,
        std: <S as RawData>::Elem,
    ) -> Result<Self, InitError>
       where StandardNormal: Distribution<<S as RawData>::Elem>,
             S: DataOwned,
             Sh: ShapeBuilder<Dim = D>,
             <S as RawData>::Elem: Float { ... }
    fn uniform<Sh>(
        shape: Sh,
        dk: <S as RawData>::Elem,
    ) -> Result<Self, InitError>
       where S: DataOwned,
             Sh: ShapeBuilder<Dim = D>,
             <S as RawData>::Elem: Clone + Neg<Output = <S as RawData>::Elem> + SampleUniform,
             <<S as RawData>::Elem as SampleUniform>::Sampler: Clone { ... }
    fn uniform_from_seed<Sh>(
        shape: Sh,
        start: <S as RawData>::Elem,
        stop: <S as RawData>::Elem,
        key: u64,
    ) -> Result<Self, InitError>
       where S: DataOwned,
             Sh: ShapeBuilder<Dim = D>,
             <S as RawData>::Elem: Clone + SampleUniform,
             <<S as RawData>::Elem as SampleUniform>::Sampler: Clone { ... }
    fn uniform_along<Sh>(shape: Sh, axis: usize) -> Result<Self, InitError>
       where Sh: ShapeBuilder<Dim = D>,
             S: DataOwned,
             <S as RawData>::Elem: Float + FromPrimitive + SampleUniform,
             <<S as RawData>::Elem as SampleUniform>::Sampler: Clone { ... }
    fn uniform_between<Sh>(
        shape: Sh,
        a: <S as RawData>::Elem,
        b: <S as RawData>::Elem,
    ) -> Result<Self, InitError>
       where Sh: ShapeBuilder<Dim = D>,
             S: DataOwned,
             <S as RawData>::Elem: Clone + SampleUniform,
             <<S as RawData>::Elem as SampleUniform>::Sampler: Clone { ... }
}Expand description
This trait provides the base methods required for initializing tensors with random values.
The trait is similar to the RandomExt trait provided by the ndarray_rand crate,
however, it is designed to be more generic, extensible, and optimized for neural network
initialization routines. Initialize is implemented for ArrayBase as well as
ParamsBase allowing you to randomly initialize new tensors and
parameters.
Required Methods§
fn rand<Sh, Ds>(shape: Sh, distr: Ds) -> Self
fn rand_with<Sh, Ds, R>(shape: Sh, distr: Ds, rng: &mut R) -> Selfwhere
    R: RngCore + ?Sized,
    Ds: Distribution<<S as RawData>::Elem>,
    Sh: ShapeBuilder<Dim = D>,
    S: DataOwned,
Provided Methods§
fn bernoulli<Sh>(shape: Sh, p: f64) -> Result<Self, BernoulliError>
Sourcefn glorot_normal<Sh>(shape: Sh) -> Selfwhere
    Sh: ShapeBuilder<Dim = D>,
    StandardNormal: Distribution<<S as RawData>::Elem>,
    S: DataOwned,
    <S as RawData>::Elem: Float + FromPrimitive,
 
fn glorot_normal<Sh>(shape: Sh) -> Selfwhere
    Sh: ShapeBuilder<Dim = D>,
    StandardNormal: Distribution<<S as RawData>::Elem>,
    S: DataOwned,
    <S as RawData>::Elem: Float + FromPrimitive,
Initialize the object according to the Glorot Initialization scheme.
Sourcefn glorot_uniform<Sh>(shape: Sh) -> Result<Self, InitError>where
    S: DataOwned,
    Sh: ShapeBuilder<Dim = D>,
    <S as RawData>::Elem: Float + FromPrimitive + SampleUniform,
    <<S as RawData>::Elem as SampleUniform>::Sampler: Clone,
 
fn glorot_uniform<Sh>(shape: Sh) -> Result<Self, InitError>where
    S: DataOwned,
    Sh: ShapeBuilder<Dim = D>,
    <S as RawData>::Elem: Float + FromPrimitive + SampleUniform,
    <<S as RawData>::Elem as SampleUniform>::Sampler: Clone,
Initialize the object according to the Glorot Initialization scheme.
Sourcefn lecun_normal<Sh>(shape: Sh) -> Selfwhere
    StandardNormal: Distribution<<S as RawData>::Elem>,
    S: DataOwned,
    Sh: ShapeBuilder<Dim = D>,
    <S as RawData>::Elem: Float,
 
fn lecun_normal<Sh>(shape: Sh) -> Selfwhere
    StandardNormal: Distribution<<S as RawData>::Elem>,
    S: DataOwned,
    Sh: ShapeBuilder<Dim = D>,
    <S as RawData>::Elem: Float,
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.
Sourcefn normal<Sh>(
    shape: Sh,
    mean: <S as RawData>::Elem,
    std: <S as RawData>::Elem,
) -> Result<Self, Error>where
    StandardNormal: Distribution<<S as RawData>::Elem>,
    S: DataOwned,
    Sh: ShapeBuilder<Dim = D>,
    <S as RawData>::Elem: Float,
 
fn normal<Sh>(
    shape: Sh,
    mean: <S as RawData>::Elem,
    std: <S as RawData>::Elem,
) -> Result<Self, Error>where
    StandardNormal: Distribution<<S as RawData>::Elem>,
    S: DataOwned,
    Sh: ShapeBuilder<Dim = D>,
    <S as RawData>::Elem: Float,
Given a shape, mean, and standard deviation generate a new object using the Normal distribution
fn randc<Sh>(
    shape: Sh,
    re: <S as RawData>::Elem,
    im: <S as RawData>::Elem,
) -> Selfwhere
    S: DataOwned,
    Sh: ShapeBuilder<Dim = D>,
    ComplexDistribution<<S as RawData>::Elem>: Distribution<<S as RawData>::Elem>,
Sourcefn stdnorm<Sh>(shape: Sh) -> Self
 
fn stdnorm<Sh>(shape: Sh) -> Self
Generate a random array using the StandardNormal distribution
Sourcefn 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
Sourcefn truncnorm<Sh>(
    shape: Sh,
    mean: <S as RawData>::Elem,
    std: <S as RawData>::Elem,
) -> Result<Self, InitError>where
    StandardNormal: Distribution<<S as RawData>::Elem>,
    S: DataOwned,
    Sh: ShapeBuilder<Dim = D>,
    <S as RawData>::Elem: Float,
 
fn truncnorm<Sh>(
    shape: Sh,
    mean: <S as RawData>::Elem,
    std: <S as RawData>::Elem,
) -> Result<Self, InitError>where
    StandardNormal: Distribution<<S as RawData>::Elem>,
    S: DataOwned,
    Sh: ShapeBuilder<Dim = D>,
    <S as RawData>::Elem: Float,
Initialize the object using the TruncatedNormal distribution
Sourcefn uniform<Sh>(shape: Sh, dk: <S as RawData>::Elem) -> Result<Self, InitError>where
    S: DataOwned,
    Sh: ShapeBuilder<Dim = D>,
    <S as RawData>::Elem: Clone + Neg<Output = <S as RawData>::Elem> + SampleUniform,
    <<S as RawData>::Elem as SampleUniform>::Sampler: Clone,
 
fn uniform<Sh>(shape: Sh, dk: <S as RawData>::Elem) -> Result<Self, InitError>where
    S: DataOwned,
    Sh: ShapeBuilder<Dim = D>,
    <S as RawData>::Elem: Clone + Neg<Output = <S as RawData>::Elem> + SampleUniform,
    <<S as RawData>::Elem as SampleUniform>::Sampler: Clone,
initialize the object using the Uniform distribution with values bounded by +/- dk
Sourcefn uniform_from_seed<Sh>(
    shape: Sh,
    start: <S as RawData>::Elem,
    stop: <S as RawData>::Elem,
    key: u64,
) -> Result<Self, InitError>where
    S: DataOwned,
    Sh: ShapeBuilder<Dim = D>,
    <S as RawData>::Elem: Clone + SampleUniform,
    <<S as RawData>::Elem as SampleUniform>::Sampler: Clone,
 
fn uniform_from_seed<Sh>(
    shape: Sh,
    start: <S as RawData>::Elem,
    stop: <S as RawData>::Elem,
    key: u64,
) -> Result<Self, InitError>where
    S: DataOwned,
    Sh: ShapeBuilder<Dim = D>,
    <S as RawData>::Elem: Clone + SampleUniform,
    <<S as RawData>::Elem as SampleUniform>::Sampler: Clone,
randomly initialize the object using the Uniform distribution with values between
the start and stop params using some random seed.
Sourcefn uniform_along<Sh>(shape: Sh, axis: usize) -> Result<Self, InitError>where
    Sh: ShapeBuilder<Dim = D>,
    S: DataOwned,
    <S as RawData>::Elem: Float + FromPrimitive + SampleUniform,
    <<S as RawData>::Elem as SampleUniform>::Sampler: Clone,
 
fn uniform_along<Sh>(shape: Sh, axis: usize) -> Result<Self, InitError>where
    Sh: ShapeBuilder<Dim = D>,
    S: DataOwned,
    <S as RawData>::Elem: Float + FromPrimitive + SampleUniform,
    <<S as RawData>::Elem as SampleUniform>::Sampler: Clone,
initialize the object using the Uniform distribution with values bounded by the
size of the specified axis.
The values are bounded by +/- dk where dk = 1 / size(axis).
Sourcefn uniform_between<Sh>(
    shape: Sh,
    a: <S as RawData>::Elem,
    b: <S as RawData>::Elem,
) -> Result<Self, InitError>where
    Sh: ShapeBuilder<Dim = D>,
    S: DataOwned,
    <S as RawData>::Elem: Clone + SampleUniform,
    <<S as RawData>::Elem as SampleUniform>::Sampler: Clone,
 
fn uniform_between<Sh>(
    shape: Sh,
    a: <S as RawData>::Elem,
    b: <S as RawData>::Elem,
) -> Result<Self, InitError>where
    Sh: ShapeBuilder<Dim = D>,
    S: DataOwned,
    <S as RawData>::Elem: Clone + SampleUniform,
    <<S as RawData>::Elem as SampleUniform>::Sampler: Clone,
initialize the object using the Uniform distribution with values between then given
bounds, a and b.
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.