mirror of
https://github.com/wassname/ray.git
synced 2026-07-13 08:10:21 +08:00
Fix documentation.
This commit is contained in:
@@ -112,13 +112,6 @@ def add(a, b):
|
||||
return a + b
|
||||
```
|
||||
|
||||
The information passed to the `@ray.remote` decorator includes type information
|
||||
for the arguments and for the return values of the function. Because of the
|
||||
distinction that we make between *submitting a task* and *executing the task*,
|
||||
we require type information so that we can catch type errors when the remote
|
||||
function is called instead of catching them when the task is actually executed
|
||||
(which could be much later and could be on a different machine).
|
||||
|
||||
### Remote functions
|
||||
|
||||
Whereas in regular Python, calling `add(1, 2)` would return `3`, in Ray, calling
|
||||
|
||||
@@ -88,9 +88,7 @@ def train_cnn_and_compute_accuracy(hyperparameters, train_images, train_labels,
|
||||
return validation_accuracy
|
||||
```
|
||||
|
||||
The only difference is that we added the `@ray.remote` decorator specifying a
|
||||
little bit of type information (the input is a dictionary along with some numpy
|
||||
arrays, and the return value is a float).
|
||||
The only difference is that we added the `@ray.remote` decorator.
|
||||
|
||||
Now a call to `train_cnn_and_compute_accuracy` does not execute the function. It
|
||||
submits the task to the scheduler and returns an object ID for the output
|
||||
|
||||
@@ -102,9 +102,7 @@ def grad(theta, xs, ys):
|
||||
return grad
|
||||
```
|
||||
|
||||
The only difference is that we added the `@ray.remote` decorator specifying a
|
||||
little bit of type information (the inputs consist of numpy arrays, `loss`
|
||||
returns a float, and `grad` returns a numpy array).
|
||||
The only difference is that we added the `@ray.remote` decorator.
|
||||
|
||||
Now, it is easy to speed up the computation of the full loss and the full
|
||||
gradient.
|
||||
|
||||
Reference in New Issue
Block a user