Skip to content

Commit

Permalink
style: black isort
Browse files Browse the repository at this point in the history
  • Loading branch information
Dariush Wahdany committed Dec 13, 2023
1 parent 6ed5d05 commit 9fb61a9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/learning_ff/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from .least_squares import dp_least_squares
from .prototypes import give_private_prototypes
__all__ = ["dp_least_squares", "give_private_prototypes"]

__all__ = ["dp_least_squares", "give_private_prototypes"]
13 changes: 6 additions & 7 deletions src/learning_ff/least_squares.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def dp_covariance(
cov = X_clip.T @ X_clip
# Add Gaussian noise to the matrix
cov += rng.normal(
scale=clipping_norm**2 * noise_multiplier * np.sqrt(k_classes), size=(d,d)
scale=clipping_norm**2 * noise_multiplier * np.sqrt(k_classes), size=(d, d)
)
return cov

Expand Down Expand Up @@ -65,11 +65,11 @@ def dp_least_squares(
):
"""Build and solve the differentially private least squares problem.
Algorithm attempts to follow the description (Algorithm 3) in:
Mehta, H., Krichene, W., Thakurta, A., Kurakin, A., & Cutkosky, A. (2022).
Differentially private image classification from features.
Mehta, H., Krichene, W., Thakurta, A., Kurakin, A., & Cutkosky, A. (2022).
Differentially private image classification from features.
arXiv preprint arXiv:2211.13403.
Args:
A: (n, d) matrix of features
y: (n,) vector of labels
Expand All @@ -95,7 +95,7 @@ def dp_least_squares(
A_clip, clipping_norm, noise_multiplier, rng, k_classes=1
) # k_classes is always 1 for global G
targets = np.unique(y)
if k_classes == None:
if k_classes is None:
k_classes = np.ones(n, dtype=int)
else:
assert len(k_classes) == n # each sample has a number of positive classes
Expand All @@ -116,4 +116,3 @@ def dp_least_squares(
thetas.append(theta_class)

return np.asarray(thetas)

2 changes: 0 additions & 2 deletions src/learning_ff/prototypes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Pathed Imports
import sys
from abc import ABC, abstractmethod
from dataclasses import dataclass

Expand Down

0 comments on commit 9fb61a9

Please sign in to comment.