tensorflow / tensorflow/privacy

AssertionError: compute_gradients() on the differentially private optimizer was not called. Which means that the training is not differentially private. It happens for example in Keras training in TensorFlow 2.0+.

Open
#134 3 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2k
Forks
477
Avg merge
22h 12m
Merged PRs (30d)
1

Description

Dear Developers,

Thank you for implementing and maintaining such a great repository.
I tried to train my model without eager execution in TensorFlow version 2.3.1.
Some code snippets are below:

optimizer = DPGradientDescentGaussianOptimizer(
        l2_norm_clip=1.0,
        noise_multiplier=0.1,
        num_microbatches=args.batch_size,
        learning_rate=0.15
)

with tf.GradientTape() as gradient_tape:
    loss_real = tf.keras.losses.binary_crossentropy(tf.ones_like(Y_real), Y_real, from_logits=True)
    loss_fake = tf.keras.losses.binary_crossentropy(tf.zeros_like(Y_fake), Y_fake, from_logits=True)
    loss = loss_real + loss_fake
            
var_list = self.model.trainable_weights
grads = gradient_tape.gradient(loss, var_list)
optimizer.apply_gradients(zip(grads, var_list))

How can I solve this problem? Does TensorFlow Privacy now support the newer version of Optimizer in TensorFlow2.x?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with DPGradientDescentGaussianOptimizer and the TensorFlow 2.3.1 Keras training example in the report. Investigate why apply_gradients does not invoke compute_gradients, then verify the supported TensorFlow 2.x usage by confirming the differential-privacy assertion is no longer raised.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, tensorflow
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.