Skip to content

Commit

Permalink
renamed the simple_network.py -> resnet_18.py. And the resnet18 link …
Browse files Browse the repository at this point in the history
…to ReadMe.
  • Loading branch information
yhwen committed Sep 26, 2024
1 parent e442d1b commit 104dcdc
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion examples/hello-world/hello-pt-resnet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ instead of the SimpleNetwork.
The Job API only supports the object instance created directly out of the Python Class. It does not support
the object instance created through using the Python function. Comparing with the hello-pt example,
if we replace the SimpleNetwork() object with the resnet18(num_classes=10),
the "resnet18(num_classes=10)" creates an torchvision "ResNet" object instance out of the "resnet18" function. The job API can
the "resnet18(num_classes=10)" creates an torchvision "ResNet" object instance out of the "resnet18" function.
As shown in the [torchvision reset](https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py#L684-L705),
the resnet18 is a Python function, which creates and returns a ResNet object. The job API can
only use the "ResNet" object instance for generating the job config. It can not detect the object creating function logic in the "resnet18".

This example demonstrates how to wrap up the resnet18 Python function into a Resnet18 Python class. Then uses the Resnet18(num_classes=10)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from src.simple_network import Resnet18
from src.resnet_18 import Resnet18

from nvflare.app_opt.pt.job_config.fed_avg import FedAvgJob
from nvflare.job_config.script_runner import ScriptRunner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import os

import torch
from simple_network import Resnet18
from resnet_18 import Resnet18
from torch import nn
from torch.optim import SGD
from torch.utils.data.dataloader import DataLoader
Expand Down

0 comments on commit 104dcdc

Please sign in to comment.