Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
c519da2c
Unverified
Commit
c519da2c
authored
May 30, 2018
by
Ilya Mironov
Committed by
GitHub
May 30, 2018
Browse files
Merge pull request #4410 from LaRiffle/master
[Diff Privacy] Update README and fix code exec wrt Python 3.6
parents
191d99a7
bf3c9d8b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
16 deletions
+20
-16
research/differential_privacy/dp_sgd/README.md
research/differential_privacy/dp_sgd/README.md
+18
-14
research/differential_privacy/dp_sgd/dp_mnist/dp_mnist.py
research/differential_privacy/dp_sgd/dp_mnist/dp_mnist.py
+1
-1
research/differential_privacy/dp_sgd/dp_optimizer/dp_optimizer.py
.../differential_privacy/dp_sgd/dp_optimizer/dp_optimizer.py
+1
-1
No files found.
research/differential_privacy/dp_sgd/README.md
View file @
c519da2c
...
@@ -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
...
...
research/differential_privacy/dp_sgd/dp_mnist/dp_mnist.py
View file @
c519da2c
...
@@ -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"
,
500
00
,
tf
.
flags
.
DEFINE_integer
(
"num_training_steps"
,
1
00
,
"The number of training steps."
"The number of training steps."
"This counts number of lots."
)
"This counts number of lots."
)
...
...
research/differential_privacy/dp_sgd/dp_optimizer/dp_optimizer.py
View file @
c519da2c
...
@@ -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
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment