Orca: add save and load model doc to PyTorch Estimator quick-start. (#5504)

* feat: add save and load model doc to pytorch estimator quickstart.

* fix: fix typo.

* fix: fix typo

* fix: fix typo.

* feat: add doc to ray backend quickstart

* fix: fix typo.

* feat: add doc to ray backend quickstart
This commit is contained in:
Cengguang Zhang 2022-08-24 13:48:32 +08:00 committed by GitHub
parent 584ee6045c
commit 57d45e5deb
3 changed files with 32 additions and 4 deletions

View file

@ -130,4 +130,18 @@ for r in result:
print(r, ":", result[r]) print(r, ":", result[r])
``` ```
### **Step 5: Save and Load the Model**
Save the Estimator states (including model and optimizer) to the provided model path.
```python
est.save("mnist_model")
```
Load the Estimator states (model and possibly with optimizer) from provided model path.
```python
est.load("mnist_model")
```
**Note:** You should call `stop_orca_context()` when your application finishes. **Note:** You should call `stop_orca_context()` when your application finishes.

View file

@ -132,4 +132,18 @@ for r in result:
print(r, ":", result[r]) print(r, ":", result[r])
``` ```
### **Step 5: Save and Load the Model**
Save the Estimator states (including model and optimizer) to the provided model path.
```python
est.save("mnist_model")
```
Load the Estimator states (model and possibly with optimizer) from the provided model path.
```python
est.load("mnist_model")
```
**Note:** You should call `stop_orca_context()` when your application finishes. **Note:** You should call `stop_orca_context()` when your application finishes.

View file

@ -130,20 +130,20 @@ You could also save the model to Keras H5 format by passing `save_format='h5'`
```python ```python
# save model in SavedModel format # save model in SavedModel format
estimator.save("/tmp/cifar10_model") est.save("/tmp/cifar10_model")
# load model # load model
estimator.load("/tmp/cifar10_model") est.load("/tmp/cifar10_model")
``` ```
**2. HDF5 format** **2. HDF5 format**
```python ```python
# save model in H5 format # save model in H5 format
estimator.save("/tmp/cifar10_model.h5", save_format='h5') est.save("/tmp/cifar10_model.h5", save_format='h5')
# load model # load model
estimator.load("/tmp/cifar10_model.h5") est.load("/tmp/cifar10_model.h5")
``` ```
That's it, the same code can run seamlessly in your local laptop and to distribute K8s or Hadoop cluster. That's it, the same code can run seamlessly in your local laptop and to distribute K8s or Hadoop cluster.