# tensorflow::ops::ScatterNdUpdate Class Reference

# tensorflow::ops::ScatterNdUpdate

`#include <state_ops.h>`

Applies sparse `updates` to individual values or slices within a given.

## Summary

variable according to `indices`.

`ref` is a `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor` with rank `P` and `indices` is a `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor` of rank `Q`.

`indices` must be integer tensor, containing indices into `ref`. It must be shape \\(\[d_0, ..., d_{Q-2}, K\]\\) where `0 < K <= P`.

The innermost dimension of `indices` (with length `K`) corresponds to indices into elements (if `K = P`) or slices (if `K < P`) along the `K`th dimension of `ref`.

`updates` is `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor` of rank `Q-1+P-K` with shape:


$$\[d_0, ..., d_{Q-2}, ref.shape\[K\], ..., ref.shape\[P-1\]\].$$

<br />

For example, say we want to update 4 scattered elements to a rank-1 tensor to 8 elements. In Python, that update would look like this:


```
    ref = tf.Variable([1, 2, 3, 4, 5, 6, 7, 8])
    indices = tf.constant([[4], [3], [1] ,[7]])
    updates = tf.constant([9, 10, 11, 12])
    update = tf.scatter_nd_update(ref, indices, updates)
    with tf.Session() as sess:
      print sess.run(update)
```

<br />

The resulting update to ref would look like this:

```
[1, 11, 3, 10, 9, 6, 7, 12]
```

<br />

See `tf.scatter_nd` for more details about how to make updates to slices.

See also `tf.scatter_update` and `tf.batch_scatter_update`.

Arguments:

- scope: A [Scope](https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object
- ref: A mutable [Tensor](https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor). Should be from a [Variable](https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/ops/variable#classtensorflow_1_1ops_1_1_variable) node.
- indices: A [Tensor](https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor). Must be one of the following types: int32, int64. A tensor of indices into ref.
- updates: A [Tensor](https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor). Must have the same type as ref. A tensor of updated values to add to ref.

<br />

Optional attributes (see `https://www.tensorflow.org/versions/r2.3/api_docs/cc/struct/tensorflow/ops/scatter-nd-update/attrs#structtensorflow_1_1ops_1_1_scatter_nd_update_1_1_attrs`):

- use_locking: An optional bool. Defaults to True. If True, the assignment will be protected by a lock; otherwise the behavior is undefined, but may exhibit less contention.

<br />

Returns:

- `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output`: Same as ref. Returned as a convenience for operations that want to use the updated values after the update is done.

<br />

| ### Constructors and Destructors ||
|---|---|
| `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/ops/scatter-nd-update#classtensorflow_1_1ops_1_1_scatter_nd_update_1acb6b3b44045199decc158f661ed16c3f(const ::https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope & scope, ::https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input ref, ::https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input indices, ::https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input updates)` ||
| `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/ops/scatter-nd-update#classtensorflow_1_1ops_1_1_scatter_nd_update_1ae3aa0b51b9e1787da8db1bf0b0eff7a2(const ::https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope & scope, ::https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input ref, ::https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input indices, ::https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input updates, const https://www.tensorflow.org/versions/r2.3/api_docs/cc/struct/tensorflow/ops/scatter-nd-update/attrs#structtensorflow_1_1ops_1_1_scatter_nd_update_1_1_attrs & attrs)` ||

| ### Public attributes ||
|---|---|
| `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/ops/scatter-nd-update#classtensorflow_1_1ops_1_1_scatter_nd_update_1a8d113d05ce297b3fbdfe5ec0108a9d2a` | `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation` |
| `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/ops/scatter-nd-update#classtensorflow_1_1ops_1_1_scatter_nd_update_1a3207186292f8bca8cf869bc6a6aa2f82` | `::https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output` |

| ### Public functions ||
|---|---|
| `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/ops/scatter-nd-update#classtensorflow_1_1ops_1_1_scatter_nd_update_1aa755e0d558f6d9154ad504413b815c87() const ` | `::tensorflow::Node *` |
| `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/ops/scatter-nd-update#classtensorflow_1_1ops_1_1_scatter_nd_update_1aaf1431785e8afb4ad1f0498144a12e6b() const ` | ` `` ` |
| `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/ops/scatter-nd-update#classtensorflow_1_1ops_1_1_scatter_nd_update_1a2e39eab6b05cd85493c30752a36ca1ea() const ` | ` `` ` |

| ### Public static functions ||
|---|---|
| `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/ops/scatter-nd-update#classtensorflow_1_1ops_1_1_scatter_nd_update_1aecb251dcdebad69c21d53f5980d0dd80(bool x)` | `https://www.tensorflow.org/versions/r2.3/api_docs/cc/struct/tensorflow/ops/scatter-nd-update/attrs#structtensorflow_1_1ops_1_1_scatter_nd_update_1_1_attrs` |

| ### Structs ||
|---|---|
| [tensorflow::ops::ScatterNdUpdate::Attrs](https://www.tensorflow.org/versions/r2.3/api_docs/cc/struct/tensorflow/ops/scatter-nd-update/attrs) | Optional attribute setters for [ScatterNdUpdate](https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/ops/scatter-nd-update#classtensorflow_1_1ops_1_1_scatter_nd_update). |

## Public attributes

### operation

```
Operation operation
```

### output_ref

```
::tensorflow::Output output_ref
```

## Public functions

### ScatterNdUpdate

```
 ScatterNdUpdate(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input ref,
  ::tensorflow::Input indices,
  ::tensorflow::Input updates
)
```

### ScatterNdUpdate

```
 ScatterNdUpdate(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input ref,
  ::tensorflow::Input indices,
  ::tensorflow::Input updates,
  const ScatterNdUpdate::Attrs & attrs
)
```

### node

```
::tensorflow::Node * node() const 
```

### operator::tensorflow::Input

```
 operator::tensorflow::Input() const 
```

### operator::tensorflow::Output

```
 operator::tensorflow::Output() const 
```

## Public static functions

### UseLocking

```
Attrs UseLocking(
  bool x
)
```