<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.15.1/tensorflow/python/distribute/coordinator/remote_value.py#L53-L131) |

An asynchronously available value of a scheduled function.

#### View aliases


**Main aliases**

[`tf.distribute.coordinator.RemoteValue`](https://www.tensorflow.org/api_docs/python/tf/distribute/experimental/coordinator/RemoteValue.md.txt)

<br />

This class is used as the return value of
[`tf.distribute.experimental.coordinator.ClusterCoordinator.schedule`](https://www.tensorflow.org/versions/r2.15/api_docs/python/tf/distribute/experimental/coordinator/ClusterCoordinator.md.txt#schedule) where
the underlying value becomes available at a later time once the function has
been executed.

Using [`tf.distribute.experimental.coordinator.RemoteValue`](https://www.tensorflow.org/versions/r2.15/api_docs/python/tf/distribute/experimental/coordinator/RemoteValue.md.txt) as an input to
a subsequent function scheduled with
[`tf.distribute.experimental.coordinator.ClusterCoordinator.schedule`](https://www.tensorflow.org/versions/r2.15/api_docs/python/tf/distribute/experimental/coordinator/ClusterCoordinator.md.txt#schedule) is
currently not supported.

#### Example:

```python
strategy = tf.distribute.experimental.ParameterServerStrategy(
    cluster_resolver=...)
coordinator = (
    tf.distribute.experimental.coordinator.ClusterCoordinator(strategy))

with strategy.scope():
  v1 = tf.Variable(initial_value=0.0)
  v2 = tf.Variable(initial_value=1.0)

@tf.function
def worker_fn():
  v1.assign_add(0.1)
  v2.assign_sub(0.2)
  return v1.read_value() / v2.read_value()

result = coordinator.schedule(worker_fn)
# Note that `fetch()` gives the actual result instead of a `tf.Tensor`.
assert result.fetch() == 0.125

for _ in range(10):
  # `worker_fn` will be run on arbitrary workers that are available. The
  # `result` value will be available later.
  result = coordinator.schedule(worker_fn)
```

## Methods

### `fetch`

[View source](https://github.com/tensorflow/tensorflow/blob/v2.15.1/tensorflow/python/distribute/coordinator/remote_value.py#L97-L113)

```python
fetch()
```

Wait for the result of `RemoteValue` and return the numpy result.

This makes the value concrete by copying the remote value to local.

<br />

<br />

<br />

| Returns ||
|---|---|
| The numpy array structure of the actual output of the [`tf.function`](https://www.tensorflow.org/versions/r2.15/api_docs/python/tf/function.md.txt) associated with this `RemoteValue`, previously returned by a [`tf.distribute.experimental.coordinator.ClusterCoordinator.schedule`](https://www.tensorflow.org/versions/r2.15/api_docs/python/tf/distribute/experimental/coordinator/ClusterCoordinator.md.txt#schedule) call. This can be a single value, or a structure of values, depending on the output of the [`tf.function`](https://www.tensorflow.org/versions/r2.15/api_docs/python/tf/function.md.txt). ||

<br />

<br />

<br />

<br />

| Raises ||
|---|---|
| [`tf.errors.CancelledError`](https://www.tensorflow.org/api_docs/python/tf/errors/CancelledError.md.txt) | If the function that produces this `RemoteValue` is aborted or cancelled due to failure. |

<br />

### `get`

[View source](https://github.com/tensorflow/tensorflow/blob/v2.15.1/tensorflow/python/distribute/coordinator/remote_value.py#L115-L131)

```python
get()
```

Wait for the result of `RemoteValue` and return the tensor result.

This makes the value concrete by copying the remote tensor to local.

<br />

<br />

<br />

| Returns ||
|---|---|
| The actual output (in the form of [`tf.Tensor`](https://www.tensorflow.org/versions/r2.15/api_docs/python/tf/Tensor.md.txt)s) of the [`tf.function`](https://www.tensorflow.org/versions/r2.15/api_docs/python/tf/function.md.txt) associated with this `RemoteValue`, previously returned by a [`tf.distribute.experimental.coordinator.ClusterCoordinator.schedule`](https://www.tensorflow.org/versions/r2.15/api_docs/python/tf/distribute/experimental/coordinator/ClusterCoordinator.md.txt#schedule) call. This can be a single Tensor, or a structure of Tensors, depending on the output of the [`tf.function`](https://www.tensorflow.org/versions/r2.15/api_docs/python/tf/function.md.txt). ||

<br />

<br />

<br />

<br />

| Raises ||
|---|---|
| [`tf.errors.CancelledError`](https://www.tensorflow.org/api_docs/python/tf/errors/CancelledError.md.txt) | If the function that produces this `RemoteValue` is aborted or cancelled due to failure. |

<br />