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

Learning bug fix #18

Merged
merged 4 commits into from
Nov 1, 2022
Merged
Show file tree
Hide file tree
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
52 changes: 26 additions & 26 deletions delta/task/learning.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,33 @@

import abc
import logging
from typing import Any, Dict, Iterable, Iterator, List, Optional, Tuple, Type
from typing import Any, Dict, Iterable, List, Optional, Tuple, Type

import delta.dataset
import numpy as np
import torch
from torch.utils.data import DataLoader, Dataset
import delta.dataset

from ..dataset import split_dataset
from ..core.strategy import (
LearningStrategy,
RandomSelectStrategy,
CURVE_TYPE,
EpochMergeStrategy,
IterMergeStrategy,
WeightResultStrategy,
CURVE_TYPE,
LearningStrategy,
RandomSelectStrategy,
ResultStrategy,
SelectStrategy,
WeightResultStrategy,
)
from ..core.task import (
DataFormat,
DataLocation,
DataNode,
GraphNode,
InputGraphNode,
MapOperator,
MapReduceOperator,
Operator,
ReduceOperator,
)
from ..dataset import split_dataset
from .task import HorizontalTask

_logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -60,14 +58,14 @@ def __init__(
merge_strategy = IterMergeStrategy(merge_iteration)
super().__init__(
"FedAvg",
select_strategy(min_clients, max_clients),
merge_strategy,
result_strategy(),
wait_timeout,
connection_timeout,
False,
precision,
curve,
select_strategy=select_strategy(min_clients, max_clients),
merge_strategy=merge_strategy,
result_strategy=result_strategy(),
wait_timeout=wait_timeout,
connection_timeout=connection_timeout,
fault_tolerant=False,
precision=precision,
curve=curve,
)


Expand Down Expand Up @@ -100,14 +98,14 @@ def __init__(

super().__init__(
"FaultTolerantFedAvg",
select_strategy(min_clients, max_clients),
merge_strategy,
result_strategy(),
wait_timeout,
connection_timeout,
True,
precision,
curve,
select_strategy=select_strategy(min_clients, max_clients),
merge_strategy=merge_strategy,
result_strategy=result_strategy(),
wait_timeout=wait_timeout,
connection_timeout=connection_timeout,
fault_tolerant=True,
precision=precision,
curve=curve,
)


Expand Down Expand Up @@ -477,7 +475,9 @@ def reduce(
res[key] = tmp.item()
except ValueError:
res[key] = tmp
_logger.info(f"Round {self.round} validating result {key}: {res[key]}")
_logger.info(
f"Round {self.round} validating result {key}: {res[key]}"
)
return res

val_op = _ValidateOp(
Expand Down
4 changes: 2 additions & 2 deletions learning_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def __init__(self) -> None:
max_clients=3, # Maximum nodes allowed in each round, must be greater equal than min_clients.
merge_epoch=1, # The number of epochs to run before aggregation is performed.
merge_iteration=0, # The number of iterations to run before aggregation is performed. One of this and the above number must be 0.
wait_timeout=45, # Timeout for calculation.
wait_timeout=90, # Timeout for calculation.
connection_timeout=10, # Wait timeout for each step.
),
)
Expand Down Expand Up @@ -159,6 +159,6 @@ def state_dict(self) -> Dict[str, torch.Tensor]:
task_id = delta_node.create_task(task)
if delta_node.trace(task_id):
res = delta_node.get_result(task_id)
print(type(res))
print(res)
else:
print("Task error")
2 changes: 1 addition & 1 deletion logit_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(
wait_timeout=5, # Timeout for calculation.
connection_timeout=5, # Wait timeout for each step.
verify_timeout=360, # Timeout for the final zero knownledge verification step
enable_verify=True # whether to enable final zero knownledge verification step
enable_verify=False # whether to enable final zero knownledge verification step
)

def dataset(self):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def run_tests(self):

setup(
name="delta-task",
version="0.8.0",
version="0.8.1",
license_files=("LICENSE"),
packages=find_packages(),
include_package_data=True,
Expand Down