struct TensorflowLite::Tensor
- TensorflowLite::Tensor
- Struct
- Value
- Object
Overview
A tensor is a multi-dimensional array used as the basic data structure. This array can have any number of dimensions, and is used to represent data of various types, such as numeric, boolean, or string values.
The dimensions of a tensor are often referred to as "ranks". For instance:
- A rank 0 tensor is a scalar (a single number).
- A rank 1 tensor is a vector (a 1D array).
- A rank 2 tensor is a matrix (a 2D array).
- A rank 3 tensor is a 3D array, and so on for higher dimensions.
Each tensor in TensorFlow is also associated with a data type (such as float32, int32, or string) and a shape. The shape of a tensor is the number of elements in each dimension.
For example, a 3x3 matrix has a shape of [3, 3].
Included Modules
- Indexable(Int32)
Defined in:
tensorflow_lite/tensor.crConstructors
Macro Summary
-
to_type(klass)
type casts the tensor buffer into the appropriate crystal lang type.
Instance Method Summary
-
#as_f
provides a view into the tensor buffer as the requested type
-
#as_f32
provides a view into the tensor buffer as the requested type
-
#as_f64
provides a view into the tensor buffer as the requested type
-
#as_i
provides a view into the tensor buffer as the requested type
-
#as_i16
provides a view into the tensor buffer as the requested type
-
#as_i32
provides a view into the tensor buffer as the requested type
-
#as_i64
provides a view into the tensor buffer as the requested type
-
#as_i8
provides a view into the tensor buffer as the requested type
-
#as_type
returns a slice of the data in the correct type
-
#as_u16
provides a view into the tensor buffer as the requested type
-
#as_u32
provides a view into the tensor buffer as the requested type
-
#as_u64
provides a view into the tensor buffer as the requested type
-
#as_u8
provides a view into the tensor buffer as the requested type
-
#bytesize : Int32
the size of the buffer backing this tensor
-
#dimension_size(index : Int) : Int32
returns the number elements in this dimension or rank index
-
#dimensions : Int32
Returns the number of dimensions (sometimes referred to as rank) of the Tensor.
-
#io_count
attempts to calculate the number on inputs/outputs based on the type
-
#name : String
The friendly name of the tensor
-
#rank
Returns the number of dimensions (sometimes referred to as rank) of the Tensor.
-
#raw_data : Bytes
buffer that makes up the tensor input
-
#size
Returns the number of dimensions (sometimes referred to as rank) of the Tensor.
-
#to_slice
buffer that makes up the tensor input
-
#type : Type
The datatype this tensor holds
Constructor Detail
Macro Detail
type casts the tensor buffer into the appropriate crystal lang type.
returns a Slice of the provided klass against the buffer for manipulation
Instance Method Detail
returns the number elements in this dimension or rank index
Returns the number of dimensions (sometimes referred to as rank) of the Tensor. Will be 0 for a scalar, 1 for a vector, 2 for a matrix, 3 for a 3-dimensional tensor etc.
Returns the number of dimensions (sometimes referred to as rank) of the Tensor. Will be 0 for a scalar, 1 for a vector, 2 for a matrix, 3 for a 3-dimensional tensor etc.
Returns the number of dimensions (sometimes referred to as rank) of the Tensor. Will be 0 for a scalar, 1 for a vector, 2 for a matrix, 3 for a 3-dimensional tensor etc.
The datatype this tensor holds
the type of data it expects as input or provides as output