Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev_1.7.0' into development_main…
Browse files Browse the repository at this point in the history
…tenance_170
  • Loading branch information
Beat Buesser committed Jun 11, 2021
2 parents ed218ad + 9104486 commit 412f66d
Show file tree
Hide file tree
Showing 18 changed files with 926 additions and 116 deletions.
37 changes: 33 additions & 4 deletions art/attacks/attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,12 @@ def __init__(self, estimator):
@abc.abstractmethod
def infer(self, x: np.ndarray, y: Optional[np.ndarray] = None, **kwargs) -> np.ndarray:
"""
Infer sensitive properties (attributes, membership training records) from the targeted estimator. This method
Infer sensitive attributes from the targeted estimator. This method
should be overridden by all concrete inference attack implementations.
:param x: An array with reference inputs to be used in the attack.
:param y: Labels for `x`. This parameter is only used by some of the attacks.
:return: An array holding the inferred properties.
:return: An array holding the inferred attribute values.
"""
raise NotImplementedError

Expand All @@ -358,12 +358,41 @@ def __init__(self, estimator, attack_feature: Union[int, slice] = 0):
@abc.abstractmethod
def infer(self, x: np.ndarray, y: Optional[np.ndarray] = None, **kwargs) -> np.ndarray:
"""
Infer sensitive properties (attributes, membership training records) from the targeted estimator. This method
Infer sensitive attributes from the targeted estimator. This method
should be overridden by all concrete inference attack implementations.
:param x: An array with reference inputs to be used in the attack.
:param y: Labels for `x`. This parameter is only used by some of the attacks.
:return: An array holding the inferred properties.
:return: An array holding the inferred attribute values.
"""
raise NotImplementedError


class MembershipInferenceAttack(InferenceAttack):
"""
Abstract base class for membership inference attack classes.
"""

def __init__(self, estimator: Union["CLASSIFIER_TYPE"]):
"""
:param estimator: A trained estimator targeted for inference attack.
:type estimator: :class:`.art.estimators.estimator.BaseEstimator`
:param attack_feature: The index of the feature to be attacked.
"""
super().__init__(estimator)

@abc.abstractmethod
def infer(self, x: np.ndarray, y: Optional[np.ndarray] = None, **kwargs) -> np.ndarray:
"""
Infer membership status of samples from the target estimator. This method
should be overridden by all concrete inference attack implementations.
:param x: An array with reference inputs to be used in the attack.
:param y: Labels for `x`. This parameter is only used by some of the attacks.
:param probabilities: a boolean indicating whether to return the predicted probabilities per class, or just
the predicted class.
:return: An array holding the inferred membership status (1 indicates member of training set,
0 indicates non-member) or class probabilities.
"""
raise NotImplementedError

Expand Down
Loading

0 comments on commit 412f66d

Please sign in to comment.