Skip to content

Commit bf3c9d8

Browse files
committed
[Diff Privacy] Update README and fix code exec wrt Python 3.6
1 parent 191d99a commit bf3c9d8

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

research/differential_privacy/dp_sgd/README.md

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,23 @@ paper: https://arxiv.org/abs/1607.00133
2727

2828
Note: r0.11 might experience some problems
2929

30-
2. Bazel 0.3.1
30+
2. Bazel 0.3.1 (<em>Optional</em>)
3131

32-
3. Download MNIST data
33-
34-
TODO(xpan): Complete the link:
35-
[train](http://download.tensorflow.org/models/)
36-
[test](http://download.tensorflow.org/models/)
37-
38-
Alternatively, download the tfrecord format MNIST from:
39-
https://github.com/panyx0718/models/tree/master/slim
32+
3. Download MNIST data (tfrecord format) <br>
33+
```shell
34+
cd models/research/slim
35+
DATA_DIR=/tmp/mnist/
36+
mkdir /tmp/mnist
37+
python download_and_convert_data.py --dataset_name=mnist --dataset_dir="${DATA_DIR}"
38+
```
4039

4140
<b>How to run:</b>
4241

4342
```shell
4443
# Clone the codes under differential_privacy.
4544
# Create an empty WORKSPACE file.
46-
# Download the data to the data/ directory.
4745

48-
# List the codes.
46+
# List the codes (Optional).
4947
$ ls -R differential_privacy/
5048
differential_privacy/:
5149
dp_sgd __init__.py privacy_accountant README.md
@@ -71,21 +69,27 @@ BUILD gaussian_moments.py
7169
differential_privacy/privacy_accountant/tf:
7270
accountant.py accountant_test.py BUILD
7371

74-
# List the data.
72+
# List the data (optional).
73+
$ mv /tmp/mnist/mnist_train.tfrecord data
74+
$ mv /tmp/mnist/mnist_test.tfrecord data
7575
$ ls -R data/
7676

7777
./data:
7878
mnist_test.tfrecord mnist_train.tfrecord
7979

80-
# Build the codes.
80+
# Build the codes (optional).
8181
$ bazel build -c opt differential_privacy/...
8282

83-
# Run the mnist differntial privacy training codes.
83+
# Run the mnist differential privacy training codes.
84+
# 1. With bazel
8485
$ bazel-bin/differential_privacy/dp_sgd/dp_mnist/dp_mnist \
8586
--training_data_path=data/mnist_train.tfrecord \
8687
--eval_data_path=data/mnist_test.tfrecord \
8788
--save_path=/tmp/mnist_dir
8889

90+
# 2. Or without (by default data is in /tmp/mnist)
91+
python dp_sgd/dp_mnist/dp_mnist.py
92+
8993
...
9094
step: 1
9195
step: 2

research/differential_privacy/dp_sgd/dp_mnist/dp_mnist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
tf.flags.DEFINE_integer("batches_per_lot", 1,
3838
"Number of batches per lot.")
3939
# Together, batch_size and batches_per_lot determine lot_size.
40-
tf.flags.DEFINE_integer("num_training_steps", 50000,
40+
tf.flags.DEFINE_integer("num_training_steps", 100,
4141
"The number of training steps."
4242
"This counts number of lots.")
4343

research/differential_privacy/dp_sgd/dp_optimizer/dp_optimizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def minimize(self, loss, global_step=None, var_list=None,
138138
sanitized_grads = self.compute_sanitized_gradients(
139139
loss, var_list=var_list)
140140

141-
grads_and_vars = zip(sanitized_grads, var_list)
141+
grads_and_vars = list(zip(sanitized_grads, var_list))
142142
self._assert_valid_dtypes([v for g, v in grads_and_vars if g is not None])
143143

144144
apply_grads = self.apply_gradients(grads_and_vars,

0 commit comments

Comments
 (0)