Creates an empty tf.TensorBuffer with the specified shape and dtype.
tf.TensorBuffer
shape
dtype
The values are stored in CPU as TypedArray. Fill the buffer using buffer.set(), or by modifying directly buffer.values.
TypedArray
buffer.set()
buffer.values
When done, call buffer.toTensor() to get an immutable tf.Tensor with those values.
buffer.toTensor()
tf.Tensor
// Create a buffer and set values at particular indices.const buffer = tf.buffer([2, 2]);buffer.set(3, 0, 0);buffer.set(5, 1, 0);// Convert the buffer back to a tensor.buffer.toTensor().print(); Copy
// Create a buffer and set values at particular indices.const buffer = tf.buffer([2, 2]);buffer.set(3, 0, 0);buffer.set(5, 1, 0);// Convert the buffer back to a tensor.buffer.toTensor().print();
An array of integers defining the output tensor shape.
Optional
The dtype of the buffer. Defaults to 'float32'.
The values of the buffer as TypedArray. Defaults to zeros.
Generated using TypeDoc
Creates an empty
tf.TensorBuffer
with the specifiedshape
anddtype
.The values are stored in CPU as
TypedArray
. Fill the buffer usingbuffer.set()
, or by modifying directlybuffer.values
.When done, call
buffer.toTensor()
to get an immutabletf.Tensor
with those values.