forked from securefederatedai/openfl
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit brings following updates:
1. Remove unnecessary spaces from Workflow_Interface_102_Aggregator_Validation.ipynb 2. Upgraded protobuf to 3.20.3 in setup.py as per tensorboard requirements 3. Modified 101-torch-cnn-mnist workspace for n-level arguments 4. Added a federated runtime workspace for 102-aggregator-validation Signed-off-by: Parth Mandaliya <parthx.mandaliya@intel.com>
- Loading branch information
1 parent
4a68b40
commit 856fadb
Showing
16 changed files
with
420 additions
and
36 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
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
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
2 changes: 2 additions & 0 deletions
2
openfl-workspace/experimental/102_aggregator_validation/.workspace
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,2 @@ | ||
current_plan_name: default | ||
|
5 changes: 5 additions & 0 deletions
5
openfl-workspace/experimental/102_aggregator_validation/plan/cols.yaml
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,5 @@ | ||
# Copyright (C) 2020-2021 Intel Corporation | ||
# Licensed subject to the terms of the separately executed evaluation license agreement between Intel Corporation and you. | ||
|
||
collaborators: | ||
|
55 changes: 55 additions & 0 deletions
55
openfl-workspace/experimental/102_aggregator_validation/plan/data.yaml
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,55 @@ | ||
## Copyright (C) 2020-2021 Intel Corporation | ||
# Licensed subject to the terms of the separately executed evaluation license agreement between Intel Corporation and you. | ||
|
||
# all keys under 'collaborators' corresponds to a specific colaborator name the corresponding dictionary has data_name, data_path pairs. | ||
# Note that in the mnist case we do not store the data locally, and the data_path is used to pass an integer that helps the data object | ||
# construct the shard of the mnist dataset to be use for this collaborator. | ||
|
||
# collaborator_name ,data_directory_path | ||
col1: | ||
callable_func: | ||
settings: | ||
batch_size: 64 | ||
index: 0 | ||
n_collaborators: 4 | ||
train_dataset: src.collaborator_private_attrs.train_dataset | ||
test_dataset: src.collaborator_private_attrs.test_dataset | ||
template: src.collaborator_private_attrs.callable_to_initialize_collaborator_private_attributes | ||
|
||
col2: | ||
callable_func: | ||
settings: | ||
batch_size: 64 | ||
index: 1 | ||
n_collaborators: 4 | ||
train_dataset: src.collaborator_private_attrs.train_dataset | ||
test_dataset: src.collaborator_private_attrs.test_dataset | ||
template: src.collaborator_private_attrs.callable_to_initialize_collaborator_private_attributes | ||
|
||
col3: | ||
callable_func: | ||
settings: | ||
batch_size: 64 | ||
index: 2 | ||
n_collaborators: 4 | ||
train_dataset: src.collaborator_private_attrs.train_dataset | ||
test_dataset: src.collaborator_private_attrs.test_dataset | ||
template: src.collaborator_private_attrs.callable_to_initialize_collaborator_private_attributes | ||
|
||
col4: | ||
callable_func: | ||
settings: | ||
batch_size: 64 | ||
index: 3 | ||
n_collaborators: 4 | ||
train_dataset: src.collaborator_private_attrs.train_dataset | ||
test_dataset: src.collaborator_private_attrs.test_dataset | ||
template: src.collaborator_private_attrs.callable_to_initialize_collaborator_private_attributes | ||
|
||
aggregator: | ||
callable_func: | ||
settings: | ||
n_collaborators: 4 | ||
batch_size: 64 | ||
test_dataset: src.aggregator_private_attrs.test_dataset | ||
template: src.aggregator_private_attrs.callable_to_initialize_aggregator_private_attributes |
2 changes: 2 additions & 0 deletions
2
openfl-workspace/experimental/102_aggregator_validation/plan/defaults
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,2 @@ | ||
../../workspace/plan/defaults | ||
|
31 changes: 31 additions & 0 deletions
31
openfl-workspace/experimental/102_aggregator_validation/plan/plan.yaml
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,31 @@ | ||
# Copyright (C) 2020-2021 Intel Corporation | ||
# Licensed subject to the terms of the separately executed evaluation license agreement between Intel Corporation and you. | ||
|
||
aggregator : | ||
defaults : plan/defaults/aggregator.yaml | ||
template : openfl.experimental.component.Aggregator | ||
settings : | ||
rounds_to_train : 1 | ||
log_metric_callback : | ||
template : src.utils.write_metric | ||
|
||
|
||
collaborator : | ||
defaults : plan/defaults/collaborator.yaml | ||
template : openfl.experimental.component.Collaborator | ||
settings : {} | ||
|
||
|
||
federated_flow: | ||
template: src.flow.AggregatorValidationFlow | ||
settings: | ||
model: | ||
template: src.flow.Net | ||
settings: {} | ||
optimizer: null | ||
rounds: 3 | ||
checkpoint: true | ||
|
||
|
||
network : | ||
defaults : plan/defaults/network.yaml |
4 changes: 4 additions & 0 deletions
4
openfl-workspace/experimental/102_aggregator_validation/requirements.txt
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,4 @@ | ||
torch==1.13.1 | ||
torchvision==0.14.1 | ||
tensorboard | ||
wheel>=0.38.0 # not directly required, pinned by Snyk to avoid a vulnerability |
2 changes: 2 additions & 0 deletions
2
openfl-workspace/experimental/102_aggregator_validation/src/__init__.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,2 @@ | ||
# Copyright (C) 2020-2021 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 |
29 changes: 29 additions & 0 deletions
29
openfl-workspace/experimental/102_aggregator_validation/src/aggregator_private_attrs.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,29 @@ | ||
# Copyright (C) 2020-2023 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from copy import deepcopy | ||
|
||
import torch | ||
import torchvision | ||
|
||
|
||
mnist_test = torchvision.datasets.MNIST('files/', train=False, download=True, | ||
transform=torchvision.transforms.Compose([ | ||
torchvision.transforms.ToTensor(), | ||
torchvision.transforms.Normalize( | ||
(0.1307,), (0.3081,)) | ||
])) | ||
|
||
test_dataset = mnist_test | ||
|
||
|
||
def callable_to_initialize_aggregator_private_attributes(n_collaborators, | ||
test_dataset, batch_size): | ||
aggregator_test = deepcopy(test_dataset) | ||
aggregator_test.targets = test_dataset.targets[n_collaborators::n_collaborators + 1] | ||
aggregator_test.data = test_dataset.data[n_collaborators::n_collaborators + 1] | ||
|
||
return { | ||
'test_loader': torch.utils.data.DataLoader( | ||
aggregator_test, batch_size=batch_size, shuffle=True) | ||
} |
43 changes: 43 additions & 0 deletions
43
openfl-workspace/experimental/102_aggregator_validation/src/collaborator_private_attrs.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,43 @@ | ||
# Copyright (C) 2020-2023 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from copy import deepcopy | ||
|
||
import torch | ||
import torchvision | ||
|
||
|
||
mnist_train = torchvision.datasets.MNIST('files/', train=True, download=True, | ||
transform=torchvision.transforms.Compose([ | ||
torchvision.transforms.ToTensor(), | ||
torchvision.transforms.Normalize( | ||
(0.1307,), (0.3081,)) | ||
])) | ||
|
||
mnist_test = torchvision.datasets.MNIST('files/', train=False, download=True, | ||
transform=torchvision.transforms.Compose([ | ||
torchvision.transforms.ToTensor(), | ||
torchvision.transforms.Normalize( | ||
(0.1307,), (0.3081,)) | ||
])) | ||
|
||
train_dataset = mnist_train | ||
test_dataset = mnist_test | ||
|
||
|
||
# Setup collaborators private attributes via callable function | ||
def callable_to_initialize_collaborator_private_attributes( | ||
index, n_collaborators, train_dataset, test_dataset, batch_size): | ||
local_train = deepcopy(train_dataset) | ||
local_test = deepcopy(test_dataset) | ||
local_train.data = train_dataset.data[index::n_collaborators] | ||
local_train.targets = train_dataset.targets[index::n_collaborators] | ||
local_test.data = test_dataset.data[index::n_collaborators] | ||
local_test.targets = test_dataset.targets[index::n_collaborators] | ||
|
||
return { | ||
'train_loader': torch.utils.data.DataLoader( | ||
local_train, batch_size=batch_size, shuffle=True), | ||
'test_loader': torch.utils.data.DataLoader( | ||
local_test, batch_size=batch_size, shuffle=True) | ||
} |
Oops, something went wrong.