-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
88a4a6b
commit 7e50d19
Showing
29 changed files
with
667 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"format_version": 2, | ||
"components": [ | ||
{ | ||
"id": "web_agent", | ||
"path": "nvflare.edge.widgets.web_agent.WebAgent", | ||
"args": {} | ||
}, | ||
{ | ||
"id": "etd", | ||
"path": "nvflare.edge.widgets.etd.EdgeTaskDispatcher", | ||
"args": {} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 2 additions & 4 deletions
6
examples/advanced/edge/jobs/hello_mobile/app/config/config_fed_server.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
examples/advanced/edge/jobs/hello_mobile/app/custom/net.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
# pyre-unsafe | ||
|
||
import torch.nn as nn | ||
from torch.nn import functional as F | ||
|
||
|
||
# Basic Net for XOR | ||
class Net(nn.Module): | ||
def __init__(self): | ||
super().__init__() | ||
self.linear = nn.Linear(2, 10) | ||
self.linear2 = nn.Linear(10, 2) | ||
|
||
def forward(self, x): | ||
return self.linear2(F.sigmoid(self.linear(x))) | ||
|
||
|
||
# On device training requires the loss to be embedded in the model (and be the first output). | ||
# We wrap the original model here and add the loss calculation. This will be the model we export. | ||
class TrainingNet(nn.Module): | ||
def __init__(self, net): | ||
super().__init__() | ||
self.net = net | ||
self.loss = nn.CrossEntropyLoss() | ||
|
||
def forward(self, input, label): | ||
pred = self.net(input) | ||
return self.loss(pred, label), pred.detach().argmax(dim=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,5 @@ | |
"app": ["@ALL"] | ||
}, | ||
"min_clients": 2, | ||
"edge_method": "cnn" | ||
"edge_method": "xor" | ||
} |
40 changes: 40 additions & 0 deletions
40
examples/advanced/edge/jobs/xor_mobile/app/config/config_fed_client.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"format_version": 2, | ||
"num_rounds": 3, | ||
"executors": [ | ||
{ | ||
"tasks": [ | ||
"train" | ||
], | ||
"executor": { | ||
"id": "Executor", | ||
"path": "nvflare.app_common.executors.ham.HierarchicalAggregationManager", | ||
"args": { | ||
"learner_id": "learner", | ||
"aggregator_id": "aggregator", | ||
"aggr_timeout": 600, | ||
"min_responses": 2, | ||
"wait_time_after_min_resps_received": 5 | ||
} | ||
} | ||
} | ||
], | ||
"components": [ | ||
{ | ||
"id": "learner", | ||
"path": "nvflare.edge.executors.edge_dispatch_executor.EdgeDispatchExecutor", | ||
"args": { | ||
"wait_time": 60, | ||
"min_devices": 2, | ||
"aggregator_id": "aggregator" | ||
} | ||
}, | ||
{ | ||
"id": "aggregator", | ||
"path": "edge_json_accumulator.EdgeJsonAccumulator", | ||
"args": { | ||
"aggr_key": "data" | ||
} | ||
} | ||
] | ||
} |
13 changes: 13 additions & 0 deletions
13
examples/advanced/edge/jobs/xor_mobile/app/config/config_fed_server.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"format_version": 2, | ||
"num_rounds": 2, | ||
"workflows": [ | ||
{ | ||
"id": "edge_executorch_controller", | ||
"path": "edge_executorch_controller.EdgeExecutorchController", | ||
"args": { | ||
"num_rounds": "{num_rounds}" | ||
} | ||
} | ||
] | ||
} |
Oops, something went wrong.