[−][src]Struct autograd::tensor::Tensor
Symbolic multi-dimensional array.
Methods
impl<T: Float> Tensor<T>
[src]
pub fn get_persistent_array(&self) -> Option<&NdArray<T>>
[src]
Returns a reference to the persistent array.
Returns Some
if this tensor is made from ag::variable
or ag::constant
.
pub unsafe fn get_persistent_array_mut(&self) -> Option<&mut NdArray<T>>
[src]
Returns a mutable reference to the persistent array.
Returns Some
if this tensor is made from ag::variable
.
pub fn has_persistent_array(&self) -> bool
[src]
Returns True
if this tensor is made from ag::variable
or ag::constant
.
impl<T: Float> Tensor<T>
[src]
pub fn builder() -> TensorBuilder<T>
[src]
pub fn eval<'k, 'v>(&self, feeds: &'v [Feed<'k, 'v, T>]) -> Option<NdArray<T>>
[src]
Evaluates this tensor as an ndarray object.
extern crate ndarray; extern crate autograd as ag; let a = ag::zeros(&[2]); assert_eq!(a.eval(&[]), Some(ndarray::arr1(&[0., 0.]).into_dyn()));
See also eval.
pub fn shape(&self) -> Tensor<T>
[src]
Returns the (symbolic) shape of this tensor.
extern crate autograd as ag; let ref x: ag::Tensor<f32> = ag::zeros(&[2, 3]); let ref s = x.shape(); assert_eq!(&[2., 3.], s.eval(&[]).unwrap().as_slice().unwrap());
See also shape.
pub fn rank(&self) -> Tensor<T>
[src]
Returns the (symbolic) rank of this tensor.
extern crate ndarray; extern crate autograd as ag; let ref x: ag::Tensor<f32> = ag::zeros(&[2, 3, 4]); let ref r = x.rank(); assert_eq!(3., r.eval(&[]).unwrap()[ndarray::IxDyn(&[])]);
See also rank.
pub fn size(&self) -> Tensor<T>
[src]
Returns the (symbolic) size of this tensor.
extern crate ndarray; extern crate autograd as ag; let ref a: ag::Tensor<f32> = ag::zeros(&[4, 3]); let ref b = a.size(); assert_eq!(12., b.eval(&[]).unwrap()[ndarray::IxDyn(&[])]);
See also size.
pub fn with(&self, hook: Hook<T>) -> Tensor<T>
[src]
Registers a simple hook for a Tensor
computation.
Pre-defined hooks are
- Print - prints the evaluation result of this tensor.
- PrintShape - prints the evaluated shape of this tensor.
See also
extern crate autograd as ag; let a: ag::Tensor<f32> = ag::zeros(&[4, 2]).with(ag::Hook::Print); let b: ag::Tensor<f32> = ag::ones(&[2, 3]).with(ag::Hook::PrintShape); let c = ag::matmul(a, b); c.eval(&[]); // Zeros: // [[0.0, 0.0], // [0.0, 0.0], // [0.0, 0.0], // [0.0, 0.0]] shape=[4, 2], strides=[2, 1], layout=C (0x1) // Shape of Ones: // [2, 3]
pub fn with_fn(&self, hook: Box<dyn Fn(&ArrayViewD<T>)>) -> Tensor<T>
[src]
Registers a hook for a Tensor
computation.
See also
extern crate autograd as ag; let a: ag::Tensor<f32> = ag::ones(&[4, 2]); let b: ag::Tensor<f32> = ag::zeros(&[2, 3]); let c = ag::matmul(a, b).with_fn(Box::new(|arr| println!("My shape: {:?}", arr.shape()))); c.eval(&[]); // My shape: [4, 3]
pub fn p(&self) -> Tensor<T>
[src]
Shorthand for Tensor::with(crate::Hook::Print)
See with
extern crate autograd as ag; let a: ag::Tensor<f32> = ag::zeros(&[4, 2]).p(); a.eval(&[]); // Zeros: // [[0.0, 0.0], // [0.0, 0.0], // [0.0, 0.0], // [0.0, 0.0]] shape=[4, 2], strides=[2, 1], layout=C (0x1)
pub fn ps(&self) -> Tensor<T>
[src]
Shorthand for Tensor::with(crate::Hook::PrintShape)
See with
extern crate autograd as ag; let a: ag::Tensor<f32> = ag::zeros(&[2, 3]).ps(); a.eval(&[]); // Shape of Zeros: // [2, 3]
impl<T: Float> Tensor<T>
[src]
pub fn get(&self, i: isize) -> Tensor<T>
[src]
Looks up a symbolic element from this tensor.
Index i
can be negative.
extern crate ndarray; extern crate autograd as ag; let ref a = ag::variable(ndarray::arr2(&[[2., 3.], [4., 5.]])); let ref b = a.get(2); assert_eq!(b.eval(&[]).unwrap()[ndarray::IxDyn(&[])], 4.);
Methods from Deref<Target = Rc<TensorCore<T>>>
Trait Implementations
impl<T: Float> ArrayLike<T> for Tensor<T>
[src]
impl<'a, T: Float> Ord for &'a Tensor<T>
[src]
fn cmp(&self, other: &&'a Tensor<T>) -> Ordering
[src]
Compares the addresses of the two tensors. This can be used for ordering-based data structures (e.g. BinaryTree).
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
fn clamp(self, min: Self, max: Self) -> Self
[src]
clamp
)Restrict a value to a certain interval. Read more
impl<T: Float> Clone for Tensor<T>
[src]
fn clone(&self) -> Tensor<T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T: Float> Eq for Tensor<T>
[src]
impl<T: Float> PartialEq<Tensor<T>> for Tensor<T>
[src]
fn eq(&self, other: &Tensor<T>) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<T: Float> AsRef<Tensor<T>> for Tensor<T>
[src]
impl<'a, T: Float> PartialOrd<&'a Tensor<T>> for &'a Tensor<T>
[src]
fn partial_cmp(&self, other: &&'a Tensor<T>) -> Option<Ordering>
[src]
Compares the addresses of the two tensors. This can be used for ordering-based data structures (e.g. BinaryTree).
#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<T: Float> DerefMut for Tensor<T>
[src]
impl<T: Float> Display for Tensor<T>
[src]
impl<T: Float> Debug for Tensor<T>
[src]
impl<T: Float> Div<T> for Tensor<T>
[src]
type Output = Tensor<T>
The resulting type after applying the /
operator.
fn div(self, rhs: T) -> Self::Output
[src]
impl<'a, T: Float> Div<T> for &'a Tensor<T>
[src]
type Output = Tensor<T>
The resulting type after applying the /
operator.
fn div(self, rhs: T) -> Self::Output
[src]
impl<T: Float> Div<Tensor<T>> for f64
[src]
type Output = Tensor<T>
The resulting type after applying the /
operator.
fn div(self, rhs: Tensor<T>) -> Self::Output
[src]
impl<'a, T: Float> Div<&'a Tensor<T>> for f64
[src]
type Output = Tensor<T>
The resulting type after applying the /
operator.
fn div(self, rhs: &'a Tensor<T>) -> Self::Output
[src]
impl<T: Float> Div<Tensor<T>> for f32
[src]
type Output = Tensor<T>
The resulting type after applying the /
operator.
fn div(self, rhs: Tensor<T>) -> Self::Output
[src]
impl<'a, T: Float> Div<&'a Tensor<T>> for f32
[src]
type Output = Tensor<T>
The resulting type after applying the /
operator.
fn div(self, rhs: &'a Tensor<T>) -> Self::Output
[src]
impl<T: Float> Div<Tensor<T>> for Tensor<T>
[src]
type Output = Tensor<T>
The resulting type after applying the /
operator.
fn div(self, rhs: Tensor<T>) -> Self::Output
[src]
impl<'a, T: Float> Div<&'a Tensor<T>> for Tensor<T>
[src]
type Output = Tensor<T>
The resulting type after applying the /
operator.
fn div(self, rhs: &Tensor<T>) -> Self::Output
[src]
impl<'a, T: Float> Div<Tensor<T>> for &'a Tensor<T>
[src]
type Output = Tensor<T>
The resulting type after applying the /
operator.
fn div(self, rhs: Tensor<T>) -> Self::Output
[src]
impl<'a, 'b, T: Float> Div<&'a Tensor<T>> for &'b Tensor<T>
[src]
type Output = Tensor<T>
The resulting type after applying the /
operator.
fn div(self, rhs: &Tensor<T>) -> Self::Output
[src]
impl<T: Float> Add<T> for Tensor<T>
[src]
type Output = Tensor<T>
The resulting type after applying the +
operator.
fn add(self, rhs: T) -> Self::Output
[src]
impl<'a, T: Float> Add<T> for &'a Tensor<T>
[src]
type Output = Tensor<T>
The resulting type after applying the +
operator.
fn add(self, rhs: T) -> Self::Output
[src]
impl<T: Float> Add<Tensor<T>> for f64
[src]
type Output = Tensor<T>
The resulting type after applying the +
operator.
fn add(self, rhs: Tensor<T>) -> Self::Output
[src]
impl<'a, T: Float> Add<&'a Tensor<T>> for f64
[src]
type Output = Tensor<T>
The resulting type after applying the +
operator.
fn add(self, rhs: &'a Tensor<T>) -> Self::Output
[src]
impl<T: Float> Add<Tensor<T>> for f32
[src]
type Output = Tensor<T>
The resulting type after applying the +
operator.
fn add(self, rhs: Tensor<T>) -> Self::Output
[src]
impl<'a, T: Float> Add<&'a Tensor<T>> for f32
[src]
type Output = Tensor<T>
The resulting type after applying the +
operator.
fn add(self, rhs: &'a Tensor<T>) -> Self::Output
[src]
impl<T: Float> Add<Tensor<T>> for Tensor<T>
[src]
type Output = Tensor<T>
The resulting type after applying the +
operator.
fn add(self, rhs: Tensor<T>) -> Self::Output
[src]
impl<'a, T: Float> Add<&'a Tensor<T>> for Tensor<T>
[src]
type Output = Tensor<T>
The resulting type after applying the +
operator.
fn add(self, rhs: &Tensor<T>) -> Self::Output
[src]
impl<'a, T: Float> Add<Tensor<T>> for &'a Tensor<T>
[src]
type Output = Tensor<T>
The resulting type after applying the +
operator.
fn add(self, rhs: Tensor<T>) -> Self::Output
[src]
impl<'a, 'b, T: Float> Add<&'a Tensor<T>> for &'b Tensor<T>
[src]
type Output = Tensor<T>
The resulting type after applying the +
operator.
fn add(self, rhs: &Tensor<T>) -> Self::Output
[src]
impl<T: Float> Sub<T> for Tensor<T>
[src]
type Output = Tensor<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: T) -> Self::Output
[src]
impl<'a, T: Float> Sub<T> for &'a Tensor<T>
[src]
type Output = Tensor<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: T) -> Self::Output
[src]
impl<T: Float> Sub<Tensor<T>> for f64
[src]
type Output = Tensor<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: Tensor<T>) -> Self::Output
[src]
impl<'a, T: Float> Sub<&'a Tensor<T>> for f64
[src]
type Output = Tensor<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: &'a Tensor<T>) -> Self::Output
[src]
impl<T: Float> Sub<Tensor<T>> for f32
[src]
type Output = Tensor<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: Tensor<T>) -> Self::Output
[src]
impl<'a, T: Float> Sub<&'a Tensor<T>> for f32
[src]
type Output = Tensor<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: &'a Tensor<T>) -> Self::Output
[src]
impl<T: Float> Sub<Tensor<T>> for Tensor<T>
[src]
type Output = Tensor<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: Tensor<T>) -> Self::Output
[src]
impl<'a, T: Float> Sub<&'a Tensor<T>> for Tensor<T>
[src]
type Output = Tensor<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: &Tensor<T>) -> Self::Output
[src]
impl<'a, T: Float> Sub<Tensor<T>> for &'a Tensor<T>
[src]
type Output = Tensor<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: Tensor<T>) -> Self::Output
[src]
impl<'a, 'b, T: Float> Sub<&'a Tensor<T>> for &'b Tensor<T>
[src]
type Output = Tensor<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: &Tensor<T>) -> Self::Output
[src]
impl<T: Float> Mul<T> for Tensor<T>
[src]
type Output = Tensor<T>
The resulting type after applying the *
operator.
fn mul(self, rhs: T) -> Self::Output
[src]
impl<'a, T: Float> Mul<T> for &'a Tensor<T>
[src]
type Output = Tensor<T>
The resulting type after applying the *
operator.
fn mul(self, rhs: T) -> Self::Output
[src]
impl<T: Float> Mul<Tensor<T>> for f64
[src]
type Output = Tensor<T>
The resulting type after applying the *
operator.
fn mul(self, rhs: Tensor<T>) -> Self::Output
[src]
impl<'a, T: Float> Mul<&'a Tensor<T>> for f64
[src]
type Output = Tensor<T>
The resulting type after applying the *
operator.
fn mul(self, rhs: &'a Tensor<T>) -> Self::Output
[src]
impl<T: Float> Mul<Tensor<T>> for f32
[src]
type Output = Tensor<T>
The resulting type after applying the *
operator.
fn mul(self, rhs: Tensor<T>) -> Self::Output
[src]
impl<'a, T: Float> Mul<&'a Tensor<T>> for f32
[src]
type Output = Tensor<T>
The resulting type after applying the *
operator.
fn mul(self, rhs: &'a Tensor<T>) -> Self::Output
[src]
impl<T: Float> Mul<Tensor<T>> for Tensor<T>
[src]
type Output = Tensor<T>
The resulting type after applying the *
operator.
fn mul(self, rhs: Tensor<T>) -> Self::Output
[src]
impl<'a, T: Float> Mul<&'a Tensor<T>> for Tensor<T>
[src]
type Output = Tensor<T>
The resulting type after applying the *
operator.
fn mul(self, rhs: &Tensor<T>) -> Self::Output
[src]
impl<'a, T: Float> Mul<Tensor<T>> for &'a Tensor<T>
[src]
type Output = Tensor<T>
The resulting type after applying the *
operator.
fn mul(self, rhs: Tensor<T>) -> Self::Output
[src]
impl<'a, 'b, T: Float> Mul<&'a Tensor<T>> for &'b Tensor<T>
[src]
type Output = Tensor<T>
The resulting type after applying the *
operator.
fn mul(self, rhs: &Tensor<T>) -> Self::Output
[src]
impl<T: Float> Deref for Tensor<T>
[src]
Auto Trait Implementations
impl<T> !Sync for Tensor<T>
impl<T> Unpin for Tensor<T>
impl<T> !Send for Tensor<T>
impl<T> !UnwindSafe for Tensor<T>
impl<T> !RefUnwindSafe for Tensor<T>
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,