Id of the bucket holding the data for this tensor. Multiple arrays can point to the same bucket (e.g. when calling array.reshape()).
The data type for the array.
Unique id of this tensor.
Whether this tensor has been globally kept.
The rank type for the array (see Rank
enum).
The id of the scope this tensor is being tracked in.
The shape of the tensor.
Number of elements in the tensor.
Number of elements to skip in each dimension when indexing. See https://docs.scipy.org/doc/numpy/reference/generated/\ numpy.ndarray.strides.html
Returns the tensor data as a nested array. The transfer of data is done asynchronously.
Returns the tensor data as a nested array. The transfer of data is done synchronously.
Returns a promise of tf.TensorBuffer
that holds the underlying data.
Returns a tf.TensorBuffer
that holds the underlying data.
Returns the underlying bytes of the tensor's data.
Asynchronously downloads the values from the tf.Tensor
. Returns a
promise of TypedArray
that resolves when the computation has finished.
Synchronously downloads the values from the tf.Tensor
. This blocks the
UI thread until the values are ready, which can cause performance issues.
Copy the tensor's data to a new GPU resource. Comparing to the dataSync()
and data()
, this method prevents data from being downloaded to CPU.
For WebGL backend, the data will be stored on a densely packed texture. This means that the texture will use the RGBA channels to store value.
For WebGPU backend, the data will be stored on a buffer. There is no parameter, so can not use an user defined size to create the buffer.
For WebGL backend, a GPUData contains the new texture and its information. { tensorRef: The tensor that is associated with this texture, texture: WebGLTexture, texShape: [number, number] // [height, width] }
For WebGPU backend, a GPUData contains the new buffer and
its information.
{
tensorRef: The tensor that is associated with this buffer,
buffer: GPUBuffer,
bufSize: number
}
Remember to dispose the GPUData after it is used by
`res.tensorRef.dispose()`.
Disposes tf.Tensor
from memory.
Prints the tf.Tensor
. See tf.print
for details.
Whether to print verbose information about the tensor, including dtype and size.
Returns a human-readable description of the tensor. Useful for logging.
A
tf.Tensor
object represents an immutable, multidimensional array of numbers that has a shape and a data type.For performance reasons, functions that create tensors do not necessarily perform a copy of the data passed to them (e.g. if the data is passed as a
Float32Array
), and changes to the data will change the tensor. This is not a feature and is not supported. To avoid this behavior, use the tensor before changing the input data or create a copy withcopy = tf.add(yourTensor, 0)
.See
tf.tensor
for details on how to create atf.Tensor
.{heading: 'Tensors', subheading: 'Classes'}