Commit bf3c9d8b authored by Theo's avatar Theo
Browse files

[Diff Privacy] Update README and fix code exec wrt Python 3.6

parent 191d99a7
...@@ -27,25 +27,23 @@ paper: https://arxiv.org/abs/1607.00133 ...@@ -27,25 +27,23 @@ paper: https://arxiv.org/abs/1607.00133
Note: r0.11 might experience some problems Note: r0.11 might experience some problems
2. Bazel 0.3.1 2. Bazel 0.3.1 (<em>Optional</em>)
3. Download MNIST data 3. Download MNIST data (tfrecord format) <br>
```shell
TODO(xpan): Complete the link: cd models/research/slim
[train](http://download.tensorflow.org/models/) DATA_DIR=/tmp/mnist/
[test](http://download.tensorflow.org/models/) mkdir /tmp/mnist
python download_and_convert_data.py --dataset_name=mnist --dataset_dir="${DATA_DIR}"
Alternatively, download the tfrecord format MNIST from: ```
https://github.com/panyx0718/models/tree/master/slim
<b>How to run:</b> <b>How to run:</b>
```shell ```shell
# Clone the codes under differential_privacy. # Clone the codes under differential_privacy.
# Create an empty WORKSPACE file. # Create an empty WORKSPACE file.
# Download the data to the data/ directory.
# List the codes. # List the codes (Optional).
$ ls -R differential_privacy/ $ ls -R differential_privacy/
differential_privacy/: differential_privacy/:
dp_sgd __init__.py privacy_accountant README.md dp_sgd __init__.py privacy_accountant README.md
...@@ -71,21 +69,27 @@ BUILD gaussian_moments.py ...@@ -71,21 +69,27 @@ BUILD gaussian_moments.py
differential_privacy/privacy_accountant/tf: differential_privacy/privacy_accountant/tf:
accountant.py accountant_test.py BUILD accountant.py accountant_test.py BUILD
# List the data. # List the data (optional).
$ mv /tmp/mnist/mnist_train.tfrecord data
$ mv /tmp/mnist/mnist_test.tfrecord data
$ ls -R data/ $ ls -R data/
./data: ./data:
mnist_test.tfrecord mnist_train.tfrecord mnist_test.tfrecord mnist_train.tfrecord
# Build the codes. # Build the codes (optional).
$ bazel build -c opt differential_privacy/... $ bazel build -c opt differential_privacy/...
# Run the mnist differntial privacy training codes. # Run the mnist differential privacy training codes.
# 1. With bazel
$ bazel-bin/differential_privacy/dp_sgd/dp_mnist/dp_mnist \ $ bazel-bin/differential_privacy/dp_sgd/dp_mnist/dp_mnist \
--training_data_path=data/mnist_train.tfrecord \ --training_data_path=data/mnist_train.tfrecord \
--eval_data_path=data/mnist_test.tfrecord \ --eval_data_path=data/mnist_test.tfrecord \
--save_path=/tmp/mnist_dir --save_path=/tmp/mnist_dir
# 2. Or without (by default data is in /tmp/mnist)
python dp_sgd/dp_mnist/dp_mnist.py
... ...
step: 1 step: 1
step: 2 step: 2
......
...@@ -37,7 +37,7 @@ tf.flags.DEFINE_integer("batch_size", 600, ...@@ -37,7 +37,7 @@ tf.flags.DEFINE_integer("batch_size", 600,
tf.flags.DEFINE_integer("batches_per_lot", 1, tf.flags.DEFINE_integer("batches_per_lot", 1,
"Number of batches per lot.") "Number of batches per lot.")
# Together, batch_size and batches_per_lot determine lot_size. # Together, batch_size and batches_per_lot determine lot_size.
tf.flags.DEFINE_integer("num_training_steps", 50000, tf.flags.DEFINE_integer("num_training_steps", 100,
"The number of training steps." "The number of training steps."
"This counts number of lots.") "This counts number of lots.")
......
...@@ -138,7 +138,7 @@ class DPGradientDescentOptimizer(tf.train.GradientDescentOptimizer): ...@@ -138,7 +138,7 @@ class DPGradientDescentOptimizer(tf.train.GradientDescentOptimizer):
sanitized_grads = self.compute_sanitized_gradients( sanitized_grads = self.compute_sanitized_gradients(
loss, var_list=var_list) loss, var_list=var_list)
grads_and_vars = zip(sanitized_grads, var_list) grads_and_vars = list(zip(sanitized_grads, var_list))
self._assert_valid_dtypes([v for g, v in grads_and_vars if g is not None]) self._assert_valid_dtypes([v for g, v in grads_and_vars if g is not None])
apply_grads = self.apply_gradients(grads_and_vars, apply_grads = self.apply_gradients(grads_and_vars,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment