Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix example code #2976

Merged
merged 1 commit into from
Oct 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions docs/docs/ProgrammingGuide/pytorch.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@ Two wrappers are defined in Analytics Zoo for Pytorch:

1. TorchModel: TorchModel is a wrapper class for Pytorch model.
User may create a TorchModel by providing a Pytorch model, e.g.
```python
```python
from zoo.pipeline.api.torch import TorchModel
TorchModel.from_pytorch(torchvision.models.resnet18(pretrained=True))
```
```
The above line creates TorchModel wrapping a ResNet model, and user can use the TorchModel for
training or inference with Analytics Zoo.

2. TorchLoss: TorchLoss is a wrapper for loss functions defined by Pytorch.
User may create a TorchLoss from a Pytorch Criterion,
```python
```python
from torch import nn
from zoo.pipeline.api.torch import TorchLoss

az_criterion = TorchLoss.from_pytorch(loss=nn.MSELoss())
```
or from a custom loss function, which takes input and label as parameters
az_criterion = TorchLoss.from_pytorch(nn.MSELoss())
```
or from a custom loss function, which takes input and label as parameters

```python
```python
from torch import nn
from zoo.pipeline.api.torch import TorchLoss

Expand All @@ -44,8 +44,8 @@ or from a custom loss function, which takes input and label as parameters
loss = loss1 + 0.4 * loss2
return loss

az_criterion = TorchLoss.from_pytorch(loss=lossFunc)
```
az_criterion = TorchLoss.from_pytorch(lossFunc)
```

# Examples
Here we provide a simple end to end example, where we use TorchModel and TorchLoss to
Expand Down