• Creates a new tensor by applying sparse updates to individual values or slices to the passed in tensor according to indices. This operator is the similar to scatterNd op, except that the udpates are scattered on an existing tensor (as opposed to a zero-tensor).

    If indices contains duplicates, then we pick the last update for the index.

    If an out of bound index is found on CPU, an error is returned.

    Warning: There are some GPU specific semantics for this operation.

    • If an out of bound index is found, the index is ignored.
    • The order in which updates are applied is nondeterministic, so the output will be nondeterministic if indices contains duplicates.
    const shape = [8];
    const tensor = tf.ones(shape);
    const indices = tf.tensor2d([4, 3, 1, 7], [4, 1], 'int32');
    const updates = tf.tensor1d([9, 10, 11, 12]);

    tf.tensorScatterUpdate(tensor, indices, updates).print();
    //[1, 11, 1, 10, 9, 1, 1, 12]

    Type Parameters

    • R extends Rank

    Parameters

    • tensor: TensorLike | Tensor<R>

      A Tensor. Tensor to copy/update.

    • indices: Tensor<Rank> | TensorLike

      The tensor contains the indices into the output tensor, must have at least 2 axes: (num_updates, index_depth).

    • updates: Tensor<Rank> | TensorLike

      The tensor contains the value for the indices.

    Returns Tensor<R>

    Doc

Generated using TypeDoc