Struct burn::tensor::Data

pub struct Data<E, const D: usize> {
    pub value: Vec<E>,
    pub shape: Shape,
}
๐Ÿ‘ŽDeprecated since 0.14.0: the internal data format has changed, please use TensorData instead
Expand description

Data structure for tensors.

Fieldsยง

ยงvalue: Vec<E>
๐Ÿ‘ŽDeprecated since 0.14.0: the internal data format has changed, please use TensorData instead

The values of the tensor.

ยงshape: Shape
๐Ÿ‘ŽDeprecated since 0.14.0: the internal data format has changed, please use TensorData instead

The shape of the tensor.

Implementationsยง

ยง

impl<E, const D: usize> Data<E, D>

pub fn new(value: Vec<E>, shape: Shape) -> Data<E, D>

Constructs a new Data.

ยง

impl<const D: usize, E> Data<E, D>
where E: Element,

pub fn convert<EOther>(self) -> Data<EOther, D>
where EOther: Element,

Converts the data to a different element type.

pub fn assert_within_range<EOther>(&self, range: Range<EOther>)
where EOther: Element,

Asserts each value is within a given range.

ยงArguments
  • range - The range.
ยงPanics

If any value is not within the half-open range bounded inclusively below and exclusively above (start..end).

ยง

impl<E, const D: usize> Data<E, D>
where E: Element,

pub fn random<R>( shape: Shape, distribution: Distribution, rng: &mut R, ) -> Data<E, D>
where R: RngCore,

Populates the data with random values.

ยง

impl<E, const D: usize> Data<E, D>
where E: Debug + Element,

pub fn zeros<S>(shape: S) -> Data<E, D>
where S: Into<Shape>,

Populates the data with zeros.

ยง

impl<E, const D: usize> Data<E, D>
where E: Debug + Element,

pub fn ones(shape: Shape) -> Data<E, D>

Populates the data with ones.

ยง

impl<E, const D: usize> Data<E, D>
where E: Debug + Element,

pub fn full(shape: Shape, fill_value: E) -> Data<E, D>

Populates the data with the given value

ยง

impl<E, const D: usize> Data<E, D>
where E: Debug + Copy,

pub fn serialize(&self) -> DataSerialize<E>

Serializes the data.

ยงReturns

The serialized data.

ยง

impl<E, const D: usize> Data<E, D>
where E: Into<f64> + Clone + Debug + PartialEq,

pub fn assert_approx_eq(&self, other: &Data<E, D>, precision: usize)

Asserts the data is approximately equal to another data.

ยงArguments
  • other - The other data.
  • precision - The precision of the comparison.
ยงPanics

Panics if the data is not approximately equal.

pub fn assert_approx_eq_diff(&self, other: &Data<E, D>, tolerance: f64)

Asserts the data is approximately equal to another data.

ยงArguments
  • other - The other data.
  • tolerance - The tolerance of the comparison.
ยงPanics

Panics if the data is not approximately equal.

ยง

impl<const D: usize> Data<usize, D>

pub fn from_usize<O>(self) -> Data<O, D>
where O: FromPrimitive,

Converts the usize data to a different element type.

Trait Implementationsยง

ยง

impl<E, const D: usize> Clone for Data<E, D>
where E: Clone,

ยง

fn clone(&self) -> Data<E, D>

Returns a copy of the value. Read more
1.0.0 ยท sourceยง

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
ยง

impl<E, const D: usize> Debug for Data<E, D>
where E: Debug,

ยง

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
ยง

impl<E, const D: usize> Display for Data<E, D>
where E: Debug,

ยง

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
ยง

impl<E> From<&[E]> for Data<E, 1>
where E: Debug + Copy,

ยง

fn from(elems: &[E]) -> Data<E, 1>

Converts to this type from the input type.
ยง

impl<E, const D: usize> From<&DataSerialize<E>> for Data<E, D>
where E: Clone,

ยง

fn from(data: &DataSerialize<E>) -> Data<E, D>

Converts to this type from the input type.
ยง

impl<E, const A: usize, const B: usize, const C: usize, const D: usize> From<[[[[E; D]; C]; B]; A]> for Data<E, 4>
where E: Debug + Copy,

ยง

fn from(elems: [[[[E; D]; C]; B]; A]) -> Data<E, 4>

Converts to this type from the input type.
ยง

impl<E, const A: usize, const B: usize, const C: usize> From<[[[E; C]; B]; A]> for Data<E, 3>
where E: Debug + Copy,

ยง

fn from(elems: [[[E; C]; B]; A]) -> Data<E, 3>

Converts to this type from the input type.
ยง

impl<E, const A: usize, const B: usize> From<[[E; B]; A]> for Data<E, 2>
where E: Debug + Copy,

ยง

fn from(elems: [[E; B]; A]) -> Data<E, 2>

Converts to this type from the input type.
ยง

impl<E, const A: usize> From<[E; A]> for Data<E, 1>
where E: Debug + Copy,

ยง

fn from(elems: [E; A]) -> Data<E, 1>

Converts to this type from the input type.
ยง

impl<E, const D: usize> From<DataSerialize<E>> for Data<E, D>

ยง

fn from(data: DataSerialize<E>) -> Data<E, D>

Converts to this type from the input type.
ยง

impl<E, const D: usize> PartialEq for Data<E, D>
where E: PartialEq,

ยง

fn eq(&self, other: &Data<E, D>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 ยท sourceยง

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
ยง

impl<E, const D: usize> Eq for Data<E, D>
where E: Eq,

ยง

impl<E, const D: usize> StructuralPartialEq for Data<E, D>

Auto Trait Implementationsยง

ยง

impl<E, const D: usize> Freeze for Data<E, D>

ยง

impl<E, const D: usize> RefUnwindSafe for Data<E, D>
where E: RefUnwindSafe,

ยง

impl<E, const D: usize> Send for Data<E, D>
where E: Send,

ยง

impl<E, const D: usize> Sync for Data<E, D>
where E: Sync,

ยง

impl<E, const D: usize> Unpin for Data<E, D>
where E: Unpin,

ยง

impl<E, const D: usize> UnwindSafe for Data<E, D>
where E: UnwindSafe,

Blanket Implementationsยง

ยง

impl<T> Adaptor<()> for T

ยง

fn adapt(&self)

Adapt the type to be passed to a metric.
sourceยง

impl<T> Any for T
where T: 'static + ?Sized,

sourceยง

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
sourceยง

impl<T> Borrow<T> for T
where T: ?Sized,

sourceยง

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
sourceยง

impl<T> BorrowMut<T> for T
where T: ?Sized,

sourceยง

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
sourceยง

impl<T> CloneToUninit for T
where T: Clone,

sourceยง

unsafe fn clone_to_uninit(&self, dst: *mut T)

๐Ÿ”ฌThis is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
ยง

impl<T> Downcast<T> for T

ยง

fn downcast(&self) -> &T

ยง

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

ยง

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
ยง

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

ยง

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
sourceยง

impl<T> From<T> for T

sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

ยง

impl<T> Instrument for T

ยง

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
ยง

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
sourceยง

impl<T, U> Into<U> for T
where U: From<T>,

sourceยง

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

sourceยง

impl<T> IntoEither for T

sourceยง

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 more
sourceยง

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
ยง

impl<T> Pointable for T

ยง

const ALIGN: usize = _

The alignment of pointer.
ยง

type Init = T

The type for initializers.
ยง

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
ยง

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
ยง

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
ยง

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
sourceยง

impl<T> Same for T

sourceยง

type Output = T

Should always be Self
ยง

impl<T> ToCompactString for T
where T: Display,

ยง

fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>

Fallible version of [ToCompactString::to_compact_string()] Read more
ยง

fn to_compact_string(&self) -> CompactString

Converts the given value to a [CompactString]. Read more
ยง

impl<T> ToLine for T
where T: Display,

ยง

fn to_line(&self) -> Line<'_>

Converts the value to a [Line].
sourceยง

impl<T> ToOwned for T
where T: Clone,

sourceยง

type Owned = T

The resulting type after obtaining ownership.
sourceยง

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
sourceยง

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
ยง

impl<T> ToSpan for T
where T: Display,

ยง

fn to_span(&self) -> Span<'_>

Converts the value to a [Span].
sourceยง

impl<T> ToString for T
where T: Display + ?Sized,

sourceยง

default fn to_string(&self) -> String

Converts the given value to a String. Read more
ยง

impl<T> ToText for T
where T: Display,

ยง

fn to_text(&self) -> Text<'_>

Converts the value to a [Text].
sourceยง

impl<T, U> TryFrom<U> for T
where U: Into<T>,

sourceยง

type Error = Infallible

The type returned in the event of a conversion error.
sourceยง

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
sourceยง

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

sourceยง

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
sourceยง

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
ยง

impl<T> Upcast<T> for T

ยง

fn upcast(&self) -> Option<&T>

ยง

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

ยง

fn vzip(self) -> V

ยง

impl<T> WithSubscriber for T

ยง

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
ยง

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
ยง

impl<T> ErasedDestructor for T
where T: 'static,

ยง

impl<T> WasmNotSend for T
where T: Send,

ยง

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

ยง

impl<T> WasmNotSync for T
where T: Sync,