• Creates an empty tf.TensorBuffer with the specified shape and dtype.

    The values are stored in CPU as TypedArray. Fill the buffer using buffer.set(), or by modifying directly buffer.values.

    When done, call buffer.toTensor() to get an immutable tf.Tensor with those values.

    // 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();

    Type Parameters

    • R extends Rank

    • D extends keyof DataTypeMap = "float32"

    Parameters

    • shape: ShapeMap[R]

      An array of integers defining the output tensor shape.

    • Optional dtype: D

      The dtype of the buffer. Defaults to 'float32'.

    • Optional values: DataTypeMap[D]

      The values of the buffer as TypedArray. Defaults to zeros.

    Returns TensorBuffer<R, D>

    Doc

Generated using TypeDoc