pub struct Tensor<T: Num> { /* private fields */ }Expand description
Reference: nreHieW
Implementations§
Source§impl<T: Num> Tensor<T>
impl<T: Num> Tensor<T>
pub fn new(data: Vec<T>, shape: Vec<usize>) -> Self
pub fn from_num(num: T, shape: Vec<usize>) -> Self
pub fn reshape(&self, shape: Vec<usize>) -> Self
Sourcepub fn squeeze(&self, dim: i32) -> Self
pub fn squeeze(&self, dim: i32) -> Self
Removes dimensions from the tensor.
This function allows for the removal of dimensions from tensor.
§Notes
If the specified index dim is out of bounds,
the function will return the same tensor without any modifications.
pub fn unsqueeze(&self, dim: usize) -> Self
pub fn cat(&self, other: &Tensor<T>, dim: usize) -> Self
pub fn convolve(&self, kernel: &Tensor<T>) -> Tensor<T>
Source§impl<T: Float> Tensor<T>
impl<T: Float> Tensor<T>
Sourcepub fn randn(&self, shape: Vec<usize>) -> Selfwhere
Standard: Distribution<T>,
pub fn randn(&self, shape: Vec<usize>) -> Selfwhere
Standard: Distribution<T>,
Creates a matrix with random numbers(between 0 and 1) This is achieved using the Box-Muller transform, which generates normally distributed random numbers from uniformly distributed random numbers.
Trait Implementations§
Source§impl<T: Num> AddAssign<&Tensor<T>> for Tensor<T>
impl<T: Num> AddAssign<&Tensor<T>> for Tensor<T>
Source§fn add_assign(&mut self, rhs: &Tensor<T>)
fn add_assign(&mut self, rhs: &Tensor<T>)
Performs the
+= operation. Read moreSource§impl<T: Num> AddAssign<T> for Tensor<T>
impl<T: Num> AddAssign<T> for Tensor<T>
Source§fn add_assign(&mut self, rhs: T)
fn add_assign(&mut self, rhs: T)
Performs the
+= operation. Read moreSource§impl<T: Num> MulAssign<T> for Tensor<T>
impl<T: Num> MulAssign<T> for Tensor<T>
Source§fn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
Performs the
*= operation. Read moreSource§impl<T: Num> SubAssign<&Tensor<T>> for Tensor<T>
impl<T: Num> SubAssign<&Tensor<T>> for Tensor<T>
Source§fn sub_assign(&mut self, rhs: &Tensor<T>)
fn sub_assign(&mut self, rhs: &Tensor<T>)
Performs the
-= operation. Read moreSource§impl<T: Num> SubAssign<T> for Tensor<T>
impl<T: Num> SubAssign<T> for Tensor<T>
Source§fn sub_assign(&mut self, rhs: T)
fn sub_assign(&mut self, rhs: T)
Performs the
-= operation. Read moreimpl<T: Eq + Num> Eq for Tensor<T>
impl<T: Num> StructuralPartialEq for Tensor<T>
Auto Trait Implementations§
impl<T> Freeze for Tensor<T>
impl<T> RefUnwindSafe for Tensor<T>where
T: RefUnwindSafe,
impl<T> Send for Tensor<T>
impl<T> Sync for Tensor<T>
impl<T> Unpin for Tensor<T>where
T: Unpin,
impl<T> UnwindSafe for Tensor<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more