privpack.core.criterion module¶
Criterions are what define the learning behavior of the privatizer and adversary network. This page shows how to setup a GANCriterion in a few steps, and how to extend these with your own criterion functions.
We have defined two types of criterion functions: either of concern for utility or for privacy. To create a privacy-preserving gan criterion you insantiate the PGANCriterion class, and add the utilities and privacies needed by the privatizer and adversary using the therefore predefined functions (). An example is shown as:
binary_gan_criterion = PGANCriterion()
binary_gan_criterion.add_privacy_criterion(BinaryMutualInformation())
binary_gan_criterion.add_privacy_criterion(BinaryHammingDistance(lambd, delta_constraint))
binary_gan_criterion.add_adversary_criterion(NegativeBinaryMutualInformation())
API Documentation¶
The loss-function defined in this module are used to learn the optimal direction for a privatizer network.
This module defines the following classes:
PrivacyLoss
UtilityLoss
-
class
privpack.core.criterion.BinaryHammingDistance(lambd, delta_constraint)¶ Bases:
privpack.core.criterion.UtilityCriterion-
expected_binary_hamming_distance(release_probabilities, expected)¶ Compute the hamming distance for both possible binary values.
Parameters:
probability_releases: tensor of probabilities per release option: z=0 and z=1.
expected: expected/most utility release values.
-
-
class
privpack.core.criterion.BinaryMutualInformation¶ Bases:
privpack.core.criterion.DiscreteMutualInformation-
binary_mi_loss(release_probabilities, likelihood_x)¶ Function limited to computing the log-loss for binary cases, using discrete_mutual_information_loss.
-
-
class
privpack.core.criterion.DiscreteMutualInformation¶ Bases:
privpack.core.criterion.PrivacyCriterion-
discrete_mi_loss(release_all_probabilities, likelihood_x)¶ Compute loss variant of the mutual information between X and released Z provided the probability per possible release, and that release’s their related computed likelihoods of x. This is similar to the log-loss
probability_releases: tensor of probabilities per release option: z=0 and z=1.
likelihood_x: computed likelihood of x given z.
return the mutual information for discrete values.
-
-
class
privpack.core.criterion.GaussianMutualInformation¶ Bases:
privpack.core.criterion.PrivacyCriterionCompute the loss variant of the mutual information between Gaussian X and Release Z. This is identical to the log-likelihood: log( Q(X|Z) ).
-
gaussian_mutual_information_loss(releases, log_likelihoods)¶
-
-
class
privpack.core.criterion.MeanSquaredError(lambd, delta_constraint)¶ Bases:
privpack.core.criterion.UtilityCriterion-
expected_mean_squared_error(releases, expected)¶ Compute the mean squared error (MSE) between the releases and most utility values.
Parameters:
releases: tensor of all releases done by some privatizer network.
expected: expected/most utility release values.
-
-
class
privpack.core.criterion.NegativeBinaryMutualInformation¶
-
class
privpack.core.criterion.PGANCriterion¶ Bases:
objectCreate a criterion class
-
add_adversary_criterion(criterion: privpack.core.criterion.Criterion)¶
-
add_privacy_criterion(criterion: privpack.core.criterion.Criterion)¶
-
adversary_loss(releases, actual_private_values, actual_public_values)¶
-
privacy_loss(releases, actual_private_values, actual_public_values)¶
-
to_json_dict()¶
-
-
class
privpack.core.criterion.PrivacyCriterion¶ Bases:
privpack.core.criterion.CriterionPrivacy Criterion is a component including loss functions correlated to Information Theoretic Losses.
Using these loss function optimum can be achieved for:
Mutual Information
Maximal Leakage
Alpha-Tunable Information Leakage
-
class
privpack.core.criterion.UtilityCriterion(lambd, delta_constraint)¶ Bases:
privpack.core.criterion.CriterionUtitlity loss concerns itself with loss function related to utility/distortion (or disutility). Each utility loss is computed according to the formula:
\(\lambda max(0, E[d(X,Y)] - \delta)^2\)
At the moment this class includes:
Hamming distance