Trait dfdx::tensor::SampleTensor

source ·
pub trait SampleTensor<E>: Storage<E> {
    // Required methods
    fn try_sample_like<S: HasShape, D: Distribution<E>>(
        &self,
        src: &S,
        distr: D
    ) -> Result<Tensor<S::Shape, E, Self>, Self::Err>;
    fn try_fill_with_distr<D: Distribution<E>>(
        &self,
        storage: &mut Self::Vec,
        distr: D
    ) -> Result<(), Self::Err>;

    // Provided methods
    fn sample_uniform<S: ConstShape>(&self) -> Tensor<S, E, Self>
       where Standard: Distribution<E> { ... }
    fn sample_uniform_like<S: HasShape>(
        &self,
        src: &S
    ) -> Tensor<S::Shape, E, Self>
       where Standard: Distribution<E> { ... }
    fn sample_normal<S: ConstShape>(&self) -> Tensor<S, E, Self>
       where StandardNormal: Distribution<E> { ... }
    fn sample_normal_like<S: HasShape>(
        &self,
        src: &S
    ) -> Tensor<S::Shape, E, Self>
       where StandardNormal: Distribution<E> { ... }
    fn sample<S: ConstShape, D: Distribution<E>>(
        &self,
        distr: D
    ) -> Tensor<S, E, Self> { ... }
    fn try_sample<S: ConstShape, D: Distribution<E>>(
        &self,
        distr: D
    ) -> Result<Tensor<S, E, Self>, Self::Err> { ... }
    fn sample_like<S: HasShape, D: Distribution<E>>(
        &self,
        src: &S,
        distr: D
    ) -> Tensor<S::Shape, E, Self> { ... }
}
Expand description

Constructs tensors filled with random values from a given distribution.

Required Methods§

source

fn try_sample_like<S: HasShape, D: Distribution<E>>( &self, src: &S, distr: D ) -> Result<Tensor<S::Shape, E, Self>, Self::Err>

Fallibly samples a tensor with a given shape from a given distribution.

source

fn try_fill_with_distr<D: Distribution<E>>( &self, storage: &mut Self::Vec, distr: D ) -> Result<(), Self::Err>

Fills tensor Storage<E> with data from a given distribution

Provided Methods§

source

fn sample_uniform<S: ConstShape>(&self) -> Tensor<S, E, Self>where Standard: Distribution<E>,

Samples a const tensor from a uniform distribution

source

fn sample_uniform_like<S: HasShape>(&self, src: &S) -> Tensor<S::Shape, E, Self>where Standard: Distribution<E>,

Samples a tensor with a given shape from a uniform distribution

source

fn sample_normal<S: ConstShape>(&self) -> Tensor<S, E, Self>where StandardNormal: Distribution<E>,

Samples a const tensor from a normal distribution

source

fn sample_normal_like<S: HasShape>(&self, src: &S) -> Tensor<S::Shape, E, Self>where StandardNormal: Distribution<E>,

Samples a tensor with a given shape from a normal distribution

source

fn sample<S: ConstShape, D: Distribution<E>>( &self, distr: D ) -> Tensor<S, E, Self>

Samples a const tensor from a given distribution.

source

fn try_sample<S: ConstShape, D: Distribution<E>>( &self, distr: D ) -> Result<Tensor<S, E, Self>, Self::Err>

Fallibly samples a const tensor from a given distribution.

source

fn sample_like<S: HasShape, D: Distribution<E>>( &self, src: &S, distr: D ) -> Tensor<S::Shape, E, Self>

Samples a tensor with a given shape from a given distribution.

Implementors§

source§

impl<E: Unit> SampleTensor<E> for Cpu

source§

impl<E: Unit> SampleTensor<E> for Cudawhere Cpu: SampleTensor<E>,