-
Notifications
You must be signed in to change notification settings - Fork 94
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
Showing
8 changed files
with
69 additions
and
2 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
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from .model import default_model | ||
import flgo.benchmark.toolkits.visualization | ||
import flgo.benchmark.toolkits.partition | ||
|
||
default_model = default_model | ||
default_partitioner = flgo.benchmark.toolkits.partition.IIDPartitioner | ||
default_partition_para = {'num_clients':100} | ||
visualize = flgo.benchmark.toolkits.visualization.visualize_by_class | ||
|
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 @@ | ||
""" | ||
train_data (torch.utils.data.Dataset), | ||
test_data (torch.utils.data.Dataset), | ||
and the model (torch.nn.Module) should be implemented here. | ||
""" | ||
import torch.nn | ||
|
||
train_data = None | ||
test_data = None | ||
|
||
def get_model(*args, **kwargs) -> torch.nn.Module: | ||
raise NotImplementedError |
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,14 @@ | ||
import os | ||
from flgo.benchmark.toolkits.cv.classification import GeneralCalculator, FromDatasetPipe, FromDatasetGenerator | ||
from .config import train_data, test_data | ||
|
||
class TaskGenerator(FromDatasetGenerator): | ||
def __init__(self): | ||
super(TaskGenerator, self).__init__(benchmark=os.path.split(os.path.dirname(__file__))[-1], | ||
train_data=train_data, test_data=test_data) | ||
|
||
class TaskPipe(FromDatasetPipe): | ||
def __init__(self, task_path): | ||
super(TaskPipe, self).__init__(task_path, train_data, test_data) | ||
|
||
TaskCalculator = GeneralCalculator |
17 changes: 17 additions & 0 deletions
17
flgo/benchmark/toolkits/cv/classification/temp/model/default_model.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,17 @@ | ||
from ..config import get_model | ||
from flgo.utils.fmodule import FModule | ||
|
||
class Model(FModule): | ||
def __init__(self): | ||
super().__init__() | ||
self.model = get_model() | ||
|
||
def forward(self, *args, **kwargs): | ||
return self.model(*args, **kwargs) | ||
|
||
def init_local_module(object): | ||
pass | ||
|
||
def init_global_module(object): | ||
if 'Server' in object.__class__.__name__: | ||
object.model = Model().to(object.device) |
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