pub struct TensorBase<S, D>{ /* private fields */ }Expand description
the TensorBase struct is the base type for all tensors in the library.
Implementations§
Source§impl<A, S, D> TensorBase<S, D>
impl<A, S, D> TensorBase<S, D>
Sourcepub const fn from_ndarray(store: ArrayBase<S, D>) -> Self
pub const fn from_ndarray(store: ArrayBase<S, D>) -> Self
create a new TensorBase from the given store.
Sourcepub fn from_shape_fn<Sh, F>(shape: Sh, f: F) -> Self
pub fn from_shape_fn<Sh, F>(shape: Sh, f: F) -> Self
create a new TensorBase from the given shape and a function to fill it.
Sourcepub fn from_fn_with_shape<Sh, F>(shape: Sh, f: F) -> Self
pub fn from_fn_with_shape<Sh, F>(shape: Sh, f: F) -> Self
create a new TensorBase from the given shape and a function to fill it.
Sourcepub fn ones<Sh>(shape: Sh) -> Self
pub fn ones<Sh>(shape: Sh) -> Self
returns a new instance of the TensorBase with the given shape and values initialized
to zero.
Sourcepub fn zeros<Sh>(shape: Sh) -> Self
pub fn zeros<Sh>(shape: Sh) -> Self
returns a new instance of the TensorBase with the given shape and values initialized
to zero.
Sourcepub fn get<Ix>(&self, index: Ix) -> Option<&A>
pub fn get<Ix>(&self, index: Ix) -> Option<&A>
returns a reference to the element at the given index, if any
Source§impl<A, S, D> TensorBase<S, D>
impl<A, S, D> TensorBase<S, D>
Sourcepub fn random<Sh, Ds>(shape: Sh, distr: Ds) -> Selfwhere
Ds: Distribution<A>,
Sh: ShapeBuilder<Dim = D>,
pub fn random<Sh, Ds>(shape: Sh, distr: Ds) -> Selfwhere
Ds: Distribution<A>,
Sh: ShapeBuilder<Dim = D>,
generate a new tensor with the given shape and randomly initialized values
Sourcepub fn random_with<Sh, Ds, R>(shape: Sh, distr: Ds, rng: &mut R) -> Self
pub fn random_with<Sh, Ds, R>(shape: Sh, distr: Ds, rng: &mut R) -> Self
generates a randomly initialized set of parameters with the given shape using the output of the given distribution