• Gather slices from tensor x's axis axis according to indices.

    const x = tf.tensor1d([1, 2, 3, 4]);
    const indices = tf.tensor1d([1, 3, 3], 'int32');

    x.gather(indices).print();
    const x = tf.tensor2d([1, 2, 3, 4], [2, 2]);
    const indices = tf.tensor1d([1, 1, 0], 'int32');

    x.gather(indices).print();

    Type Parameters

    Parameters

    • x: TensorLike | T

      The input tensor whose slices are to be gathered.

    • indices: Tensor<Rank> | TensorLike

      The indices of the values to extract.

    • Optional axis: number

      The axis over which to select values. Defaults to 0.

    • Optional batchDims: number

      Optional. The number of batch dimensions. It must be less than or equal to rank(indices). Defaults to 0. The output tensor will have shape of x.shape[:axis] + indices.shape[batchDims:] + x.shape[axis + 1:]

    Returns T

    Doc

Generated using TypeDoc