Skip to content
This repository has been archived by the owner on Apr 27, 2024. It is now read-only.

Added docstrings, type hints to following functions: #19

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

S1ddh4rth
Copy link

_compute_accuracy, accuracy_scorer, marginal_gain_scorer

_compute_accuracy, accuracy_scorer,  marginal_gain_scorer
Copy link
Owner

@eigengravy eigengravy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also format using black, you can setup vscode to use it by default

tinyfl/scorer.py Outdated Show resolved Hide resolved
tinyfl/scorer.py Outdated Show resolved Hide resolved
tinyfl/scorer.py Outdated Show resolved Hide resolved
tinyfl/scorer.py Outdated Show resolved Hide resolved
tinyfl/scorer.py Outdated Show resolved Hide resolved
tinyfl/scorer.py Outdated Show resolved Hide resolved
@eigengravy eigengravy linked an issue Jun 14, 2023 that may be closed by this pull request
accuracy_scorer, marginal_gain_scorer, removing unecessary imports
@@ -23,7 +57,7 @@ def marginal_gain_scorer(weights, prev_scores, testloader):
]


def multikrum_scorer(weights):
def multikrum_scorer(weights: List[Mapping[str, Any]]):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return type is list of floats

Suggested change
def multikrum_scorer(weights: List[Mapping[str, Any]]):
def multikrum_scorer(weights: List[Mapping[str, Any]]) -> List[float]:

model = create_model()
model.load_state_dict(weight)
return test_model(model, testloader)[0]


def accuracy_scorer(weights, testloader):
def accuracy_scorer(weights: List[Mapping[str, Any]], testloader: DataLoader)-> List(float):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

Suggested change
def accuracy_scorer(weights: List[Mapping[str, Any]], testloader: DataLoader)-> List(float):
def accuracy_scorer(weights: List[Mapping[str, Any]], testloader: DataLoader)-> List[float]:

@@ -63,7 +63,7 @@ def test_model(model: Model, testloader: DataLoader) -> Tuple[float, float]:
return 100 * correct, test_loss


def fedavg_models(weights):
def fedavg_models(weights: list[dict])-> dict:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refer previous comments

@@ -23,7 +23,7 @@ def __init__(self) -> None:
nn.Linear(128, 10),
)

def forward(self, x):
def forward(self, x: DataLoader)-> DataLoader:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

take lite

Suggested change
def forward(self, x: DataLoader)-> DataLoader:
def forward(self, x):

@S1ddh4rth
Copy link
Author

Sorry I think I pushed the scorer.py changes by accident, I was waiting until after Druva implemented the other ML Model to complete it properly. I'll Fix these

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Documentation
2 participants