Skip to content

Commit

Permalink
updates for sweep
Browse files Browse the repository at this point in the history
  • Loading branch information
brettbj committed Jun 21, 2017
1 parent 9fe7106 commit 4b647b4
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 13 deletions.
5 changes: 4 additions & 1 deletion dp_gan.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,10 @@ def build_discriminator():
test_history = defaultdict(list)
privacy_history = []

with tf.Session() as sess:
config = tf.ConfigProto()
config.gpu_options.allow_growth=True

with tf.Session(config=config) as sess:
eps = tf.placeholder(tf.float32)
delta = tf.placeholder(tf.float32)

Expand Down
41 changes: 36 additions & 5 deletions noise_sweep.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
CUDA_VISIBLE_DEVICES=0 python dp_gan.py --clip_value 0.0001 --noise 8 --epochs 500 --lr 0.002 --batch_size 100 --prefix p0_ --seed 123
CUDA_VISIBLE_DEVICES=0 python dp_gan.py --clip_value 0.0001 --noise 8 --epochs 500 --lr 0.002 --batch_size 100 --prefix p1_ --seed 234
CUDA_VISIBLE_DEVICES=0 python dp_gan.py --clip_value 0.0001 --noise 8 --epochs 500 --lr 0.002 --batch_size 100 --prefix p2_ --seed 567
CUDA_VISIBLE_DEVICES=0 python dp_gan.py --clip_value 0.0001 --noise 8 --epochs 500 --lr 0.002 --batch_size 100 --prefix p3_ --seed 678
CUDA_VISIBLE_DEVICES=0 python dp_gan.py --clip_value 0.0001 --noise 8 --epochs 500 --lr 0.002 --batch_size 100 --prefix p4_ --seed 789
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 2 --clip_value 1e-05 --epochs 500 --lr 0.0002 --batch_size 1 --prefix 2_1e-05_0.0002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 2 --clip_value 0.0001 --epochs 500 --lr 0.0002 --batch_size 1 --prefix 2_0.0001_0.0002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 2 --clip_value 0.001 --epochs 500 --lr 0.0002 --batch_size 1 --prefix 2_0.001_0.0002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 3 --clip_value 1e-05 --epochs 500 --lr 0.0002 --batch_size 1 --prefix 3_1e-05_0.0002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 3 --clip_value 0.0001 --epochs 500 --lr 0.0002 --batch_size 1 --prefix 3_0.0001_0.0002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 3 --clip_value 0.001 --epochs 500 --lr 0.0002 --batch_size 1 --prefix 3_0.001_0.0002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 4 --clip_value 1e-05 --epochs 500 --lr 0.0002 --batch_size 1 --prefix 4_1e-05_0.0002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 4 --clip_value 0.0001 --epochs 500 --lr 0.0002 --batch_size 1 --prefix 4_0.0001_0.0002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 4 --clip_value 0.001 --epochs 500 --lr 0.0002 --batch_size 1 --prefix 4_0.001_0.0002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 8 --clip_value 1e-05 --epochs 500 --lr 0.0002 --batch_size 1 --prefix 8_1e-05_0.0002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 8 --clip_value 0.0001 --epochs 500 --lr 0.0002 --batch_size 1 --prefix 8_0.0001_0.0002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 8 --clip_value 0.001 --epochs 500 --lr 0.0002 --batch_size 1 --prefix 8_0.001_0.0002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 0.25 --clip_value 1e-05 --epochs 500 --lr 0.0002 --batch_size 1 --prefix 0.25_1e-05_0.0002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 0.25 --clip_value 0.0001 --epochs 500 --lr 0.0002 --batch_size 1 --prefix 0.25_0.0001_0.0002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 0.25 --clip_value 0.001 --epochs 500 --lr 0.0002 --batch_size 1 --prefix 0.25_0.001_0.0002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 0.5 --clip_value 1e-05 --epochs 500 --lr 0.0002 --batch_size 1 --prefix 0.5_1e-05_0.0002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 0.5 --clip_value 0.0001 --epochs 500 --lr 0.0002 --batch_size 1 --prefix 0.5_0.0001_0.0002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 0.5 --clip_value 0.001 --epochs 500 --lr 0.0002 --batch_size 1 --prefix 0.5_0.001_0.0002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 1 --clip_value 1e-05 --epochs 500 --lr 0.0002 --batch_size 1 --prefix 1_1e-05_0.0002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 1 --clip_value 0.0001 --epochs 500 --lr 0.0002 --batch_size 1 --prefix 1_0.0001_0.0002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 1 --clip_value 0.001 --epochs 500 --lr 0.0002 --batch_size 1 --prefix 1_0.001_0.0002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 1.5 --clip_value 1e-05 --epochs 500 --lr 0.0002 --batch_size 1 --prefix 1.5_1e-05_0.0002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 1.5 --clip_value 0.0001 --epochs 500 --lr 0.0002 --batch_size 1 --prefix 1.5_0.0001_0.0002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 1.5 --clip_value 0.001 --epochs 500 --lr 0.0002 --batch_size 1 --prefix 1.5_0.001_0.0002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 0.25 --clip_value 1e-05 --epochs 500 --lr 0.002 --batch_size 1 --prefix 0.25_1e-05_0.002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 0.25 --clip_value 0.0001 --epochs 500 --lr 0.002 --batch_size 1 --prefix 0.25_0.0001_0.002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 0.25 --clip_value 0.001 --epochs 500 --lr 0.002 --batch_size 1 --prefix 0.25_0.001_0.002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 0.5 --clip_value 1e-05 --epochs 500 --lr 0.002 --batch_size 1 --prefix 0.5_1e-05_0.002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 0.5 --clip_value 0.0001 --epochs 500 --lr 0.002 --batch_size 1 --prefix 0.5_0.0001_0.002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 0.5 --clip_value 0.001 --epochs 500 --lr 0.002 --batch_size 1 --prefix 0.5_0.001_0.002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 1 --clip_value 1e-05 --epochs 500 --lr 0.002 --batch_size 1 --prefix 1_1e-05_0.002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 1 --clip_value 0.0001 --epochs 500 --lr 0.002 --batch_size 1 --prefix 1_0.0001_0.002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 1 --clip_value 0.001 --epochs 500 --lr 0.002 --batch_size 1 --prefix 1_0.001_0.002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 1.5 --clip_value 1e-05 --epochs 500 --lr 0.002 --batch_size 1 --prefix 1.5_1e-05_0.002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 1.5 --clip_value 0.0001 --epochs 500 --lr 0.002 --batch_size 1 --prefix 1.5_0.0001_0.002_
CUDA_VISIBLE_DEVICES="1" python dp_gan.py --noise 1.5 --clip_value 0.001 --epochs 500 --lr 0.002 --batch_size 1 --prefix 1.5_0.001_0.002_
41 changes: 36 additions & 5 deletions noise_sweep_2.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
CUDA_VISIBLE_DEVICES=1 python dp_gan.py --clip_value 0.0001 --noise 8 --epochs 500 --lr 0.002 --batch_size 100 --prefix p5_
CUDA_VISIBLE_DEVICES=1 python dp_gan.py --clip_value 0.0001 --noise 8 --epochs 500 --lr 0.002 --batch_size 100 --prefix p6_
CUDA_VISIBLE_DEVICES=1 python dp_gan.py --clip_value 0.0001 --noise 8 --epochs 500 --lr 0.002 --batch_size 100 --prefix p7_
CUDA_VISIBLE_DEVICES=1 python dp_gan.py --clip_value 0.0001 --noise 8 --epochs 500 --lr 0.002 --batch_size 100 --prefix p8_
CUDA_VISIBLE_DEVICES=1 python dp_gan.py --clip_value 0.0001 --noise 8 --epochs 500 --lr 0.002 --batch_size 100 --prefix p9_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 2 --clip_value 1e-05 --epochs 500 --lr 2e-05 --batch_size 1 --prefix 2_1e-05_2e-05_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 2 --clip_value 0.0001 --epochs 500 --lr 2e-05 --batch_size 1 --prefix 2_0.0001_2e-05_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 2 --clip_value 0.001 --epochs 500 --lr 2e-05 --batch_size 1 --prefix 2_0.001_2e-05_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 3 --clip_value 1e-05 --epochs 500 --lr 2e-05 --batch_size 1 --prefix 3_1e-05_2e-05_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 3 --clip_value 0.0001 --epochs 500 --lr 2e-05 --batch_size 1 --prefix 3_0.0001_2e-05_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 3 --clip_value 0.001 --epochs 500 --lr 2e-05 --batch_size 1 --prefix 3_0.001_2e-05_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 4 --clip_value 1e-05 --epochs 500 --lr 2e-05 --batch_size 1 --prefix 4_1e-05_2e-05_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 4 --clip_value 0.0001 --epochs 500 --lr 2e-05 --batch_size 1 --prefix 4_0.0001_2e-05_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 4 --clip_value 0.001 --epochs 500 --lr 2e-05 --batch_size 1 --prefix 4_0.001_2e-05_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 8 --clip_value 1e-05 --epochs 500 --lr 2e-05 --batch_size 1 --prefix 8_1e-05_2e-05_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 8 --clip_value 0.0001 --epochs 500 --lr 2e-05 --batch_size 1 --prefix 8_0.0001_2e-05_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 8 --clip_value 0.001 --epochs 500 --lr 2e-05 --batch_size 1 --prefix 8_0.001_2e-05_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 0.25 --clip_value 1e-05 --epochs 500 --lr 2e-05 --batch_size 1 --prefix 0.25_1e-05_2e-05_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 0.25 --clip_value 0.0001 --epochs 500 --lr 2e-05 --batch_size 1 --prefix 0.25_0.0001_2e-05_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 0.25 --clip_value 0.001 --epochs 500 --lr 2e-05 --batch_size 1 --prefix 0.25_0.001_2e-05_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 0.5 --clip_value 1e-05 --epochs 500 --lr 2e-05 --batch_size 1 --prefix 0.5_1e-05_2e-05_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 0.5 --clip_value 0.0001 --epochs 500 --lr 2e-05 --batch_size 1 --prefix 0.5_0.0001_2e-05_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 0.5 --clip_value 0.001 --epochs 500 --lr 2e-05 --batch_size 1 --prefix 0.5_0.001_2e-05_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 1 --clip_value 1e-05 --epochs 500 --lr 2e-05 --batch_size 1 --prefix 1_1e-05_2e-05_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 1 --clip_value 0.0001 --epochs 500 --lr 2e-05 --batch_size 1 --prefix 1_0.0001_2e-05_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 1 --clip_value 0.001 --epochs 500 --lr 2e-05 --batch_size 1 --prefix 1_0.001_2e-05_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 1.5 --clip_value 1e-05 --epochs 500 --lr 2e-05 --batch_size 1 --prefix 1.5_1e-05_2e-05_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 1.5 --clip_value 0.0001 --epochs 500 --lr 2e-05 --batch_size 1 --prefix 1.5_0.0001_2e-05_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 1.5 --clip_value 0.001 --epochs 500 --lr 2e-05 --batch_size 1 --prefix 1.5_0.001_2e-05_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 2 --clip_value 1e-05 --epochs 500 --lr 0.002 --batch_size 1 --prefix 2_1e-05_0.002_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 2 --clip_value 0.0001 --epochs 500 --lr 0.002 --batch_size 1 --prefix 2_0.0001_0.002_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 2 --clip_value 0.001 --epochs 500 --lr 0.002 --batch_size 1 --prefix 2_0.001_0.002_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 3 --clip_value 1e-05 --epochs 500 --lr 0.002 --batch_size 1 --prefix 3_1e-05_0.002_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 3 --clip_value 0.0001 --epochs 500 --lr 0.002 --batch_size 1 --prefix 3_0.0001_0.002_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 3 --clip_value 0.001 --epochs 500 --lr 0.002 --batch_size 1 --prefix 3_0.001_0.002_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 4 --clip_value 1e-05 --epochs 500 --lr 0.002 --batch_size 1 --prefix 4_1e-05_0.002_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 4 --clip_value 0.0001 --epochs 500 --lr 0.002 --batch_size 1 --prefix 4_0.0001_0.002_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 4 --clip_value 0.001 --epochs 500 --lr 0.002 --batch_size 1 --prefix 4_0.001_0.002_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 8 --clip_value 1e-05 --epochs 500 --lr 0.002 --batch_size 1 --prefix 8_1e-05_0.002_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 8 --clip_value 0.0001 --epochs 500 --lr 0.002 --batch_size 1 --prefix 8_0.0001_0.002_
CUDA_VISIBLE_DEVICES="0" python dp_gan.py --noise 8 --clip_value 0.001 --epochs 500 --lr 0.002 --batch_size 1 --prefix 8_0.001_0.002_
11 changes: 9 additions & 2 deletions priv_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from privacy_accountant import accountant, utils
import argparse
import time
import sys

import pickle as pkl

Expand All @@ -15,19 +16,25 @@ def calc_priv(noise, epochs, training_size, batch_size):
target_eps = [0.125,0.25,0.5,1,2,4,8]
priv_accountant = accountant.GaussianMomentsAccountant(training_size)

print('accum privacy, batches: ' + str(num_batches))
sys.stderr.write('accum privacy, batches: ' + str(num_batches))
priv_start_time = time.clock()
privacy_accum_op = priv_accountant.accumulate_privacy_spending(
[None, None], args.noise, batch_size)
tf.global_variables_initializer().run()
for index in range(num_batches):
if index % 10000 == 0:
sys.stderr.write(str(index))
pkl.dump(privacy_history, open('./privacy/' + str(noise) + '_' +
str(epochs) + '_' + str(training_size) + '_' + str(batch_size) +
'.p', 'wb'))

with tf.control_dependencies([privacy_accum_op]):
spent_eps_deltas = priv_accountant.get_privacy_spent(
sess, target_eps=target_eps)
privacy_history.append(spent_eps_deltas)
sess.run([privacy_accum_op])

print('priv time: ', time.clock() - priv_start_time)
sys.stderr.write('priv time: ', time.clock() - priv_start_time)

if spent_eps_deltas[-3][1] > 0.0001:
raise Exception('spent privacy')
Expand Down

0 comments on commit 4b647b4

Please sign in to comment.