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§
sourcefn try_sample_like<S: HasShape, D: Distribution<E>>(
&self,
src: &S,
distr: D
) -> Result<Tensor<S::Shape, E, Self>, Self::Err>
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.
sourcefn try_fill_with_distr<D: Distribution<E>>(
&self,
storage: &mut Self::Vec,
distr: D
) -> Result<(), Self::Err>
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§
sourcefn sample_uniform<S: ConstShape>(&self) -> Tensor<S, E, Self>where
Standard: Distribution<E>,
fn sample_uniform<S: ConstShape>(&self) -> Tensor<S, E, Self>where Standard: Distribution<E>,
Samples a const tensor from a uniform distribution
sourcefn sample_uniform_like<S: HasShape>(&self, src: &S) -> Tensor<S::Shape, E, Self>where
Standard: Distribution<E>,
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
sourcefn sample_normal<S: ConstShape>(&self) -> Tensor<S, E, Self>where
StandardNormal: Distribution<E>,
fn sample_normal<S: ConstShape>(&self) -> Tensor<S, E, Self>where StandardNormal: Distribution<E>,
Samples a const tensor from a normal distribution
sourcefn sample_normal_like<S: HasShape>(&self, src: &S) -> Tensor<S::Shape, E, Self>where
StandardNormal: Distribution<E>,
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
sourcefn sample<S: ConstShape, D: Distribution<E>>(
&self,
distr: D
) -> Tensor<S, E, Self>
fn sample<S: ConstShape, D: Distribution<E>>( &self, distr: D ) -> Tensor<S, E, Self>
Samples a const tensor from a given distribution.
sourcefn try_sample<S: ConstShape, D: Distribution<E>>(
&self,
distr: D
) -> Result<Tensor<S, E, Self>, Self::Err>
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.
sourcefn sample_like<S: HasShape, D: Distribution<E>>(
&self,
src: &S,
distr: D
) -> Tensor<S::Shape, E, Self>
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.