1.1.6. aijack.attack.membership package#
1.1.6.1. Submodules#
1.1.6.2. aijack.attack.membership.membership_inference module#
- class aijack.attack.membership.membership_inference.ShadowMembershipInferenceAttack(target_model, shadow_models, attack_models)[source]#
Bases:
aijack.attack.base_attack.BaseAttacker
- attack(x, y, proba=False)[source]#
Attack victim model
- Parameters
x – target datasets which the attacker wants to classify
y – target labels which the attacker wants to classify
proba – the format of the output
- predict(pred, label)[source]#
Predict whether the given prediction came from training data or not
- Parameters
pred (torch.Tensor) – predicted probabilities on the data
label (torch.Tensor) – true label of the data which y_pred_prob is predicted on
- Returns
predicted binaru labels
1.1.6.3. aijack.attack.membership.utils module#
- class aijack.attack.membership.utils.AttackerModel(models)[source]#
Bases:
object
- fit(shadow_result)[source]#
train an attacl model with the result of shadow models
- Parameters
shadow_result (dict) – key is each class value is (shadow_data, shadow_label)
- predict(y_pred_prob, y_labels)[source]#
predict whether the given prediction came from training data or not
- Parameters
y_pred_prob (torch.Tensor) – predicted probabilities on the data
y_labels (torch.Tensor) – true label of the data which y_pred_prob is predicted on
- Returns
- result of attack
each element should be one or zero
- Return type
in_out_pred (np.array)
- predict_proba(y_pred_prob, y_labels)[source]#
- get probabilities of whether the given prediction came from
training data or not
- Parameters
y_pred_prob (torch.Tensor) – predicted probabilities on the data
y_labels (torch.Tensor) – true label of the data which y_pred_prob is predicted on
- Returns
- result of attack
each element expresses the possibility
- Return type
in_out_pred (np.array)
- class aijack.attack.membership.utils.ShadowModels(models)[source]#
Bases:
object
- Train shadow models for membership inference
reference https://arxiv.org/abs/1610.05820
- Args
models : torch models for shadow
1.1.6.4. Module contents#
Subpackage for membership inference attack, which reveals the confidential information about whether the target data is in the training dataset or not.
- class aijack.attack.membership.ShadowMembershipInferenceAttack(target_model, shadow_models, attack_models)[source]#
Bases:
aijack.attack.base_attack.BaseAttacker
- attack(x, y, proba=False)[source]#
Attack victim model
- Parameters
x – target datasets which the attacker wants to classify
y – target labels which the attacker wants to classify
proba – the format of the output
- predict(pred, label)[source]#
Predict whether the given prediction came from training data or not
- Parameters
pred (torch.Tensor) – predicted probabilities on the data
label (torch.Tensor) – true label of the data which y_pred_prob is predicted on
- Returns
predicted binaru labels