-
-
Notifications
You must be signed in to change notification settings - Fork 49k
added federated learning #13622
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
base: master
Are you sure you want to change the base?
added federated learning #13622
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
| import numpy as np | ||
|
|
||
|
|
||
| def create_client_datasets( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file machine_learning/federated_learning/federated_averaging.py, please provide doctest for the function create_client_datasets
|
|
||
| for _ in range(n_clients): | ||
| X = rng.normal(0, 1, (samples_each, n_features)) | ||
| X_bias = np.c_[np.ones((samples_each, 1)), X] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: X_bias
| return rng.normal(0, 0.01, n_params) | ||
|
|
||
|
|
||
| def mean_squared_error(params: np.ndarray, X: np.ndarray, y: np.ndarray) -> float: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide descriptive name for the parameter: X
Please provide descriptive name for the parameter: y
| return float(np.mean((predictions - y) ** 2)) | ||
|
|
||
|
|
||
| def evaluate_global_model(params: np.ndarray, client_data: List[Tuple[np.ndarray, np.ndarray]]) -> float: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file machine_learning/federated_learning/federated_averaging.py, please provide doctest for the function evaluate_global_model
| return float(total_loss / total_samples) | ||
|
|
||
|
|
||
| def client_update( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file machine_learning/federated_learning/federated_averaging.py, please provide doctest for the function client_update
|
|
||
| def client_update( | ||
| params: np.ndarray, | ||
| X: np.ndarray, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide descriptive name for the parameter: X
| def client_update( | ||
| params: np.ndarray, | ||
| X: np.ndarray, | ||
| y: np.ndarray, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide descriptive name for the parameter: y
| order = np.random.permutation(n_samples) | ||
| for i in range(0, n_samples, batch_size): | ||
| idx = order[i:i + batch_size] | ||
| Xb, yb = X[idx], y[idx] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: Xb
| return aggregated | ||
|
|
||
|
|
||
| def run_federated_training( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file machine_learning/federated_learning/federated_averaging.py, please provide doctest for the function run_federated_training
for more information, see https://pre-commit.ci
Describe your change:
Checklist: