pub struct TensorExpansion<T, S, const D: usize, const I: usize> { /* private fields */ }
Expand description
A combination of dimension names and a tensor. The provided dimensions increase
the dimensionality of the TensorRef exposed to more than the dimensionality of the TensorRef
this is created from, by adding additional dimensions with a length of one.
use easy_ml::tensors::Tensor;
use easy_ml::tensors::views::{TensorView, TensorExpansion};
let vector = Tensor::from([("a", 2)], vec![ 16, 8 ]);
let matrix = vector.expand([(1, "b")]);
let also_matrix = TensorView::from(TensorExpansion::from(&vector, [(1, "b")]));
assert_eq!(matrix, also_matrix);
assert_eq!(matrix, Tensor::from([("a", 2), ("b", 1)], vec![ 16, 8 ]));
Note: due to limitations in Rust’s const generics support, TensorExpansion only implements
TensorRef for D from 1
to 6
.
Creates a TensorExpansion from a source and extra dimension names inserted into the shape
at the provided indexes.
Each extra dimension name adds a dimension to the tensor with a length of 1 so they
do not change the total number of elements. Hence, a vector can be viewed as a matrix
if you provide an extra row/column dimension. More generally, the tensor the TensorExpansion
exposes will have a dimensionality of D + I, where D is the dimensionality of the source,
and I is the dimensionality of the extra dimensions.
The extra dimension names can be added before any dimensions in the source’s shape, in
the range 0 inclusive to D inclusive. It is possible to add multiple dimension names before
an existing dimension.
- If any extra dimension name is already in use
- If any dimension number
d
to insert an extra dimension name into is not 0 <= d
<= D
- If the extra dimension names are not unique
Performs copy-assignment from
source
.
Read more
Formats the value using the given formatter.
Read more
Gets a mutable reference to the value at the index, if the index is in range. Otherwise
returns None.
Gets a mutable reference to the value at the index without doing any bounds checking.
For a safe alternative see
get_reference_mut.
Read more
Gets a mutable reference to the value at the index, if the index is in range. Otherwise
returns None.
Gets a mutable reference to the value at the index without doing any bounds checking.
For a safe alternative see
get_reference_mut.
Read more
Gets a mutable reference to the value at the index, if the index is in range. Otherwise
returns None.
Gets a mutable reference to the value at the index without doing any bounds checking.
For a safe alternative see
get_reference_mut.
Read more
Gets a mutable reference to the value at the index, if the index is in range. Otherwise
returns None.
Gets a mutable reference to the value at the index without doing any bounds checking.
For a safe alternative see
get_reference_mut.
Read more
Gets a mutable reference to the value at the index, if the index is in range. Otherwise
returns None.
Gets a mutable reference to the value at the index without doing any bounds checking.
For a safe alternative see
get_reference_mut.
Read more
Gets a mutable reference to the value at the index, if the index is in range. Otherwise
returns None.
Gets a mutable reference to the value at the index without doing any bounds checking.
For a safe alternative see
get_reference_mut.
Read more
Gets a mutable reference to the value at the index, if the index is in range. Otherwise
returns None.
Gets a mutable reference to the value at the index without doing any bounds checking.
For a safe alternative see
get_reference_mut.
Read more
Gets a mutable reference to the value at the index, if the index is in range. Otherwise
returns None.
Gets a mutable reference to the value at the index without doing any bounds checking.
For a safe alternative see
get_reference_mut.
Read more
Gets a mutable reference to the value at the index, if the index is in range. Otherwise
returns None.
Gets a mutable reference to the value at the index without doing any bounds checking.
For a safe alternative see
get_reference_mut.
Read more
Gets a mutable reference to the value at the index, if the index is in range. Otherwise
returns None.
Gets a mutable reference to the value at the index without doing any bounds checking.
For a safe alternative see
get_reference_mut.
Read more
Gets a mutable reference to the value at the index, if the index is in range. Otherwise
returns None.
Gets a mutable reference to the value at the index without doing any bounds checking.
For a safe alternative see
get_reference_mut.
Read more
Gets a mutable reference to the value at the index, if the index is in range. Otherwise
returns None.
Gets a mutable reference to the value at the index without doing any bounds checking.
For a safe alternative see
get_reference_mut.
Read more
Gets a mutable reference to the value at the index, if the index is in range. Otherwise
returns None.
Gets a mutable reference to the value at the index without doing any bounds checking.
For a safe alternative see
get_reference_mut.
Read more
Gets a mutable reference to the value at the index, if the index is in range. Otherwise
returns None.
Gets a mutable reference to the value at the index without doing any bounds checking.
For a safe alternative see
get_reference_mut.
Read more
Gets a mutable reference to the value at the index, if the index is in range. Otherwise
returns None.
Gets a mutable reference to the value at the index without doing any bounds checking.
For a safe alternative see
get_reference_mut.
Read more
Gets a mutable reference to the value at the index, if the index is in range. Otherwise
returns None.
Gets a mutable reference to the value at the index without doing any bounds checking.
For a safe alternative see
get_reference_mut.
Read more
Gets a mutable reference to the value at the index, if the index is in range. Otherwise
returns None.
Gets a mutable reference to the value at the index without doing any bounds checking.
For a safe alternative see
get_reference_mut.
Read more
Gets a mutable reference to the value at the index, if the index is in range. Otherwise
returns None.
Gets a mutable reference to the value at the index without doing any bounds checking.
For a safe alternative see
get_reference_mut.
Read more
Gets a mutable reference to the value at the index, if the index is in range. Otherwise
returns None.
Gets a mutable reference to the value at the index without doing any bounds checking.
For a safe alternative see
get_reference_mut.
Read more
Gets a mutable reference to the value at the index, if the index is in range. Otherwise
returns None.
Gets a mutable reference to the value at the index without doing any bounds checking.
For a safe alternative see
get_reference_mut.
Read more
Gets a mutable reference to the value at the index, if the index is in range. Otherwise
returns None.
Gets a mutable reference to the value at the index without doing any bounds checking.
For a safe alternative see
get_reference_mut.
Read more
Gets a reference to the value at the index if the index is in range. Otherwise returns None.
The shape this tensor has. See
dimensions for an overview.
The product of the lengths in the pairs define how many elements are in the tensor
(or the portion of it that is visible).
Gets a reference to the value at the index without doing any bounds checking. For a safe
alternative see
get_reference.
Read more
The way the data in this tensor is laid out in memory. In particular,
Linear
has several requirements on what is returned that must be upheld
by implementations of this trait.
Read more
Gets a reference to the value at the index if the index is in range. Otherwise returns None.
The shape this tensor has. See
dimensions for an overview.
The product of the lengths in the pairs define how many elements are in the tensor
(or the portion of it that is visible).
Gets a reference to the value at the index without doing any bounds checking. For a safe
alternative see
get_reference.
Read more
The way the data in this tensor is laid out in memory. In particular,
Linear
has several requirements on what is returned that must be upheld
by implementations of this trait.
Read more
Gets a reference to the value at the index if the index is in range. Otherwise returns None.
The shape this tensor has. See
dimensions for an overview.
The product of the lengths in the pairs define how many elements are in the tensor
(or the portion of it that is visible).
Gets a reference to the value at the index without doing any bounds checking. For a safe
alternative see
get_reference.
Read more
The way the data in this tensor is laid out in memory. In particular,
Linear
has several requirements on what is returned that must be upheld
by implementations of this trait.
Read more
Gets a reference to the value at the index if the index is in range. Otherwise returns None.
The shape this tensor has. See
dimensions for an overview.
The product of the lengths in the pairs define how many elements are in the tensor
(or the portion of it that is visible).
Gets a reference to the value at the index without doing any bounds checking. For a safe
alternative see
get_reference.
Read more
The way the data in this tensor is laid out in memory. In particular,
Linear
has several requirements on what is returned that must be upheld
by implementations of this trait.
Read more
Gets a reference to the value at the index if the index is in range. Otherwise returns None.
The shape this tensor has. See
dimensions for an overview.
The product of the lengths in the pairs define how many elements are in the tensor
(or the portion of it that is visible).
Gets a reference to the value at the index without doing any bounds checking. For a safe
alternative see
get_reference.
Read more
The way the data in this tensor is laid out in memory. In particular,
Linear
has several requirements on what is returned that must be upheld
by implementations of this trait.
Read more
Gets a reference to the value at the index if the index is in range. Otherwise returns None.
The shape this tensor has. See
dimensions for an overview.
The product of the lengths in the pairs define how many elements are in the tensor
(or the portion of it that is visible).
Gets a reference to the value at the index without doing any bounds checking. For a safe
alternative see
get_reference.
Read more
The way the data in this tensor is laid out in memory. In particular,
Linear
has several requirements on what is returned that must be upheld
by implementations of this trait.
Read more
Gets a reference to the value at the index if the index is in range. Otherwise returns None.
The shape this tensor has. See
dimensions for an overview.
The product of the lengths in the pairs define how many elements are in the tensor
(or the portion of it that is visible).
Gets a reference to the value at the index without doing any bounds checking. For a safe
alternative see
get_reference.
Read more
The way the data in this tensor is laid out in memory. In particular,
Linear
has several requirements on what is returned that must be upheld
by implementations of this trait.
Read more
Gets a reference to the value at the index if the index is in range. Otherwise returns None.
The shape this tensor has. See
dimensions for an overview.
The product of the lengths in the pairs define how many elements are in the tensor
(or the portion of it that is visible).
Gets a reference to the value at the index without doing any bounds checking. For a safe
alternative see
get_reference.
Read more
The way the data in this tensor is laid out in memory. In particular,
Linear
has several requirements on what is returned that must be upheld
by implementations of this trait.
Read more
Gets a reference to the value at the index if the index is in range. Otherwise returns None.
The shape this tensor has. See
dimensions for an overview.
The product of the lengths in the pairs define how many elements are in the tensor
(or the portion of it that is visible).
Gets a reference to the value at the index without doing any bounds checking. For a safe
alternative see
get_reference.
Read more
The way the data in this tensor is laid out in memory. In particular,
Linear
has several requirements on what is returned that must be upheld
by implementations of this trait.
Read more
Gets a reference to the value at the index if the index is in range. Otherwise returns None.
The shape this tensor has. See
dimensions for an overview.
The product of the lengths in the pairs define how many elements are in the tensor
(or the portion of it that is visible).
Gets a reference to the value at the index without doing any bounds checking. For a safe
alternative see
get_reference.
Read more
The way the data in this tensor is laid out in memory. In particular,
Linear
has several requirements on what is returned that must be upheld
by implementations of this trait.
Read more
Gets a reference to the value at the index if the index is in range. Otherwise returns None.
The shape this tensor has. See
dimensions for an overview.
The product of the lengths in the pairs define how many elements are in the tensor
(or the portion of it that is visible).
Gets a reference to the value at the index without doing any bounds checking. For a safe
alternative see
get_reference.
Read more
The way the data in this tensor is laid out in memory. In particular,
Linear
has several requirements on what is returned that must be upheld
by implementations of this trait.
Read more
Gets a reference to the value at the index if the index is in range. Otherwise returns None.
The shape this tensor has. See
dimensions for an overview.
The product of the lengths in the pairs define how many elements are in the tensor
(or the portion of it that is visible).
Gets a reference to the value at the index without doing any bounds checking. For a safe
alternative see
get_reference.
Read more
The way the data in this tensor is laid out in memory. In particular,
Linear
has several requirements on what is returned that must be upheld
by implementations of this trait.
Read more
Gets a reference to the value at the index if the index is in range. Otherwise returns None.
The shape this tensor has. See
dimensions for an overview.
The product of the lengths in the pairs define how many elements are in the tensor
(or the portion of it that is visible).
Gets a reference to the value at the index without doing any bounds checking. For a safe
alternative see
get_reference.
Read more
The way the data in this tensor is laid out in memory. In particular,
Linear
has several requirements on what is returned that must be upheld
by implementations of this trait.
Read more
Gets a reference to the value at the index if the index is in range. Otherwise returns None.
The shape this tensor has. See
dimensions for an overview.
The product of the lengths in the pairs define how many elements are in the tensor
(or the portion of it that is visible).
Gets a reference to the value at the index without doing any bounds checking. For a safe
alternative see
get_reference.
Read more
The way the data in this tensor is laid out in memory. In particular,
Linear
has several requirements on what is returned that must be upheld
by implementations of this trait.
Read more
Gets a reference to the value at the index if the index is in range. Otherwise returns None.
The shape this tensor has. See
dimensions for an overview.
The product of the lengths in the pairs define how many elements are in the tensor
(or the portion of it that is visible).
Gets a reference to the value at the index without doing any bounds checking. For a safe
alternative see
get_reference.
Read more
The way the data in this tensor is laid out in memory. In particular,
Linear
has several requirements on what is returned that must be upheld
by implementations of this trait.
Read more
Gets a reference to the value at the index if the index is in range. Otherwise returns None.
The shape this tensor has. See
dimensions for an overview.
The product of the lengths in the pairs define how many elements are in the tensor
(or the portion of it that is visible).
Gets a reference to the value at the index without doing any bounds checking. For a safe
alternative see
get_reference.
Read more
The way the data in this tensor is laid out in memory. In particular,
Linear
has several requirements on what is returned that must be upheld
by implementations of this trait.
Read more
Gets a reference to the value at the index if the index is in range. Otherwise returns None.
The shape this tensor has. See
dimensions for an overview.
The product of the lengths in the pairs define how many elements are in the tensor
(or the portion of it that is visible).
Gets a reference to the value at the index without doing any bounds checking. For a safe
alternative see
get_reference.
Read more
The way the data in this tensor is laid out in memory. In particular,
Linear
has several requirements on what is returned that must be upheld
by implementations of this trait.
Read more
Gets a reference to the value at the index if the index is in range. Otherwise returns None.
The shape this tensor has. See
dimensions for an overview.
The product of the lengths in the pairs define how many elements are in the tensor
(or the portion of it that is visible).
Gets a reference to the value at the index without doing any bounds checking. For a safe
alternative see
get_reference.
Read more
The way the data in this tensor is laid out in memory. In particular,
Linear
has several requirements on what is returned that must be upheld
by implementations of this trait.
Read more
Gets a reference to the value at the index if the index is in range. Otherwise returns None.
The shape this tensor has. See
dimensions for an overview.
The product of the lengths in the pairs define how many elements are in the tensor
(or the portion of it that is visible).
Gets a reference to the value at the index without doing any bounds checking. For a safe
alternative see
get_reference.
Read more
The way the data in this tensor is laid out in memory. In particular,
Linear
has several requirements on what is returned that must be upheld
by implementations of this trait.
Read more
Gets a reference to the value at the index if the index is in range. Otherwise returns None.
The shape this tensor has. See
dimensions for an overview.
The product of the lengths in the pairs define how many elements are in the tensor
(or the portion of it that is visible).
Gets a reference to the value at the index without doing any bounds checking. For a safe
alternative see
get_reference.
Read more
The way the data in this tensor is laid out in memory. In particular,
Linear
has several requirements on what is returned that must be upheld
by implementations of this trait.
Read more
Gets a reference to the value at the index if the index is in range. Otherwise returns None.
The shape this tensor has. See
dimensions for an overview.
The product of the lengths in the pairs define how many elements are in the tensor
(or the portion of it that is visible).
Gets a reference to the value at the index without doing any bounds checking. For a safe
alternative see
get_reference.
Read more
The way the data in this tensor is laid out in memory. In particular,
Linear
has several requirements on what is returned that must be upheld
by implementations of this trait.
Read more
Immutably borrows from an owned value.
Read more
Mutably borrows from an owned value.
Read more
Returns the argument unchanged.
Calls U::from(self)
.
That is, this conversion is whatever the implementation of
From<T> for U
chooses to do.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning.
Read more
Uses borrowed data to replace owned data, usually by cloning.
Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.