forked from 626_privacy/tensorflow_privacy
fix language in colab
PiperOrigin-RevId: 281372393
This commit is contained in:
parent
28d6db4c92
commit
8d185c81c7
1 changed files with 9 additions and 9 deletions
|
@ -90,12 +90,12 @@
|
|||
"id": "TUphKzYu01O9"
|
||||
},
|
||||
"source": [
|
||||
"[Differential privacy](https://en.wikipedia.org/wiki/Differential_privacy) (DP) is a framework that allows for measuring the privacy guarantees provided by a Machine Learning (ML) algorithm with respect to its input data. Recent advances allow the training of ML models with DP, greatly mitigating the risk of exposing sensitive training data in ML. Intuitively, a model trained with DP should not be affected by any single training example (or small set of training examples) in its dataset. \n",
|
||||
"[Differential privacy](https://en.wikipedia.org/wiki/Differential_privacy) (DP) is a framework for measuring the privacy guarantees provided by an algorithm. Through the lens of differential privacy, we can design machine learning algorithms that responsibly train models on private data. Learning with differential privacy provides provable guarantees of privacy, mitigating the risk of exposing sensitive training data in machine learning. Intuitively, a model trained with differential privacy should not be affected by any single training example, or small set of training examples, in its data set. This mitigates the risk of exposing sensitive training data in ML.\n",
|
||||
"\n",
|
||||
"The basic idea of this approach, called differentially private stochastic gradient descent (DP-SGD), is to modify the gradients\n",
|
||||
"used in stochastic gradient descent (SGD), which lies at the core of almost all deep learning algorithms. Models trained with DP-SGD provide provable differential privacy guarantees for their input data. There are two modifications made to the vanilla SGD algorithm:\n",
|
||||
"\n",
|
||||
"1. The sensitivity of each gradient is bounded by *clipping* the gradient computed for each training point. This limits how much each training point can possibly impact model parameters.\n",
|
||||
"1. First, the sensitivity of each gradient needs to be bounded. In other words, we need to limit how much each individual training point sampled in a minibatch can influence gradient computations and the resulting updates applied to model parameters. This can be done by *clipping* each gradient computed on each training point.\n",
|
||||
"2. *Random noise* is sampled and added to the clipped gradients to make it statistically impossible to know whether or not a particular data point was included in the training dataset by comparing the updates SGD applies when it operates with or without this particular data point in the training dataset.\n",
|
||||
"\n",
|
||||
"This tutorial uses [tf.keras](https://www.tensorflow.org/guide/keras) to train a convolutional neural network (CNN) to recognize handwritten digits with the DP-SGD optimizer provided by the TensorFlow Privacy library. TensorFlow Privacy provides code that wraps an existing TensorFlow optimizer to create a variant that implements DP-SGD."
|
||||
|
@ -253,10 +253,10 @@
|
|||
"source": [
|
||||
"DP-SGD has three privacy-specific hyperparameters and one existing hyperamater that you must tune:\n",
|
||||
"\n",
|
||||
"1. `l2_norm_clip` (float) - The maximum Euclidean (L2) norm of each individual gradient that is computed on an individual training example from a minibatch. This hyperparameter is used to bound the optimizer's sensitivity to individual training points. \n",
|
||||
"1. `l2_norm_clip` (float) - The maximum Euclidean (L2) norm of each gradient that is applied to update model parameters. This hyperparameter is used to bound the optimizer's sensitivity to individual training points. \n",
|
||||
"2. `noise_multiplier` (float) - The amount of noise sampled and added to gradients during training. Generally, more noise results in better privacy (often, but not necessarily, at the expense of lower utility).\n",
|
||||
"3. `microbatches` (int) - The input data for each step (i.e., batch) of your original training algorithm is split into this many microbatches. Generally, increasing this will improve your utility but increase your overall training time. The total number of examples consumed in one global step remains the same. Your input batch size should be an integer multiple of the number of microbatches.\n",
|
||||
"4. `learning_rate` (float) - This hyperparameter already exists in vanilla SGD. The higher the learning rate, the more each update matters. If the updates are noisy (such as when the additive noise is large compared to the clipping threshold), the learning rate must be kept low for the training procedure to converge. \n",
|
||||
"3. `microbatches` (int) - Each batch of data is split in smaller units called microbatches. By default, each microbatch should contain a single training example. This allows us to clip gradients on a per-example basis rather than after they have been averaged across the minibatch. This in turn decreases the (negative) effect of clipping on signal found in the gradient and typically maximizes utility. However, computational overhead can be reduced by increasing the size of microbatches to include more than one training examples. The average gradient across these multiple training examples is then clipped. The total number of examples consumed in a batch, i.e., one step of gradient descent, remains the same. The number of microbatches should evenly divide the batch size. \n",
|
||||
"4. `learning_rate` (float) - This hyperparameter already exists in vanilla SGD. The higher the learning rate, the more each update matters. If the updates are noisy (such as when the additive noise is large compared to the clipping threshold), a low learning rate may help the training procedure converge. \n",
|
||||
"\n",
|
||||
"Use the hyperparameter values below to obtain a reasonably accurate model (95% test accuracy):"
|
||||
]
|
||||
|
@ -387,11 +387,11 @@
|
|||
"source": [
|
||||
"## Measure the differential privacy guarantee\n",
|
||||
"\n",
|
||||
"Perform a privacy analysis to measure the DP guarantee achieved by an ML algorithm. Knowing the level of DP achieved enables the objective comparison of two models to determine which of the two is more privacy-preserving. At a high level, a privacy analysis measures how including or excluding any particular point in the training dataset is likely to change the probability that the ML algorithm learns any particular set of parameters. \n",
|
||||
"Perform a privacy analysis to measure the DP guarantee achieved by a training algorithm. Knowing the level of DP achieved enables the objective comparison of two training runs to determine which of the two is more privacy-preserving. At a high level, the privacy analysis measures how much a potential adversary can improve their guess about properties of any individual training point by observing the outcome of our training procedure (e.g., model updates and parameters). \n",
|
||||
"\n",
|
||||
"This probability is sometimes called the **privacy budget**. A lower privacy budget ensures a stronger privacy guarantee. Intuitively, this is because if a single training point does not affect the outcome of learning, the information contained in the training point cannot be memorized by the ML algorithm, and the privacy of the individual who contributed this training point to the dataset is preserved.\n",
|
||||
"This guarantee is sometimes referred to as the **privacy budget**. A lower privacy budget bounds more tightly an adversary's ability to improve their guess. This ensures a stronger privacy guarantee. Intuitively, this is because it is harder for a single training point to affect the outcome of learning: for instance, the information contained in the training point cannot be memorized by the ML algorithm and the privacy of the individual who contributed this training point to the dataset is preserved.\n",
|
||||
"\n",
|
||||
"In this tutorial, the privacy analysis is performed in the framework of Rényi Differential Privacy (RDP), which is a generalization of pure DP based on [this paper](https://arxiv.org/abs/1702.07476) that is particularly well suited for DP-SGD.\n",
|
||||
"In this tutorial, the privacy analysis is performed in the framework of Rényi Differential Privacy (RDP), which is a relaxation of pure DP based on [this paper](https://arxiv.org/abs/1702.07476) that is particularly well suited for DP-SGD.\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n"
|
||||
|
@ -407,7 +407,7 @@
|
|||
"Two metrics are used to express the DP guarantee of an ML algorithm:\n",
|
||||
"\n",
|
||||
"1. Delta ($\\delta$) - Bounds the probability of the privacy guarantee not holding. A rule of thumb is to set it to be less than the inverse of the size of the training dataset. In this tutorial, it is set to **10^-5** as the MNIST dataset has 60,000 training points.\n",
|
||||
"2. Epsilon ($\\epsilon$) - Measures the strength of the privacy guarantee by bounding how much the probability of a particular model output can vary by including (or excluding) a single training point. A smaller value for $\\epsilon$ implies a better privacy guarantee. However, the $\\epsilon$ value is only an upper bound and a large value could still mean good practical privacy.\n",
|
||||
"2. Epsilon ($\\epsilon$) - This is the privacy budget. It measures the strength of the privacy guarantee by bounding how much the probability of a particular model output can vary by including (or excluding) a single training point. A smaller value for $\\epsilon$ implies a better privacy guarantee. However, the $\\epsilon$ value is only an upper bound and a large value could still mean good privacy in practice.\n",
|
||||
"\n",
|
||||
"Tensorflow Privacy provides a tool, `compute_dp_sgd_privacy.py`, to compute the value of $\\epsilon$ given a fixed value of $\\delta$ and the following hyperparameters from the training process:\n",
|
||||
"\n",
|
||||
|
|
Loading…
Reference in a new issue