[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to track privacy spent in tff.learning.dp_aggregator? #1376

Open
cozek opened this issue May 3, 2021 · 3 comments
Open

How to track privacy spent in tff.learning.dp_aggregator? #1376

cozek opened this issue May 3, 2021 · 3 comments

Comments

@cozek
Copy link
cozek commented May 3, 2021

Hi, I am running the mnist example using the following code ?

iterative_process = tff.learning.build_federated_averaging_process(
    model_fn,
    client_optimizer_fn=lambda: tf.keras.optimizers.SGD(learning_rate=0.02),
    server_optimizer_fn=lambda: tf.keras.optimizers.SGD(learning_rate=1.0),
    model_update_aggregation_factory = tff.learning.dp_aggregator(
        0.1,10
    )
)
state = iterative_process.initialize()
for round_num in range(1, NUM_ROUNDS):
  state, metrics = iterative_process.next(state, federated_train_data)
  print('round {:2d}, metrics={}'.format(round_num, metrics))
round  1, metrics=OrderedDict([('broadcast', ()), ('aggregation', OrderedDict([('zeroing', OrderedDict([('dp_query_metrics', OrderedDict([('clip', 0.10891904)])), ('dp', ())])), ('zeroing_norm', 21.0), ('zeroed_count', 0)])), ('train', OrderedDict([('sparse_categorical_accuracy', 0.12633745), ('loss', 2.2959495)])), ('stat', OrderedDict([('num_examples', 9720)]))])
round  2, metrics=OrderedDict([('broadcast', ()), ('aggregation', OrderedDict([('zeroing', OrderedDict([('dp_query_metrics', OrderedDict([('clip', 0.10740396)])), ('dp', ())])), ('zeroing_norm', 20.099854), ('zeroed_count', 0)])), ('train', OrderedDict([('sparse_categorical_accuracy', 0.14917696), ('loss', 2.2878613)])), ('stat', OrderedDict([('num_examples', 9720)]))])
round  3, metrics=OrderedDict([('broadcast', ()), ('aggregation', OrderedDict([('zeroing', OrderedDict([('dp_query_metrics', OrderedDict([('clip', 0.10791755)])), ('dp', ())])), ('zeroing_norm', 19.24022), ('zeroed_count', 0)])), ('train', OrderedDict([('sparse_categorical_accuracy', 0.15298355), ('loss', 2.281409)])), ('stat', OrderedDict([('num_examples', 9720)]))])
round  4, metrics=OrderedDict([('broadcast', ()), ('aggregation', OrderedDict([('zeroing', OrderedDict([('dp_query_metrics', OrderedDict([('clip', 0.11691465)])), ('dp', ())])), ('zeroing_norm', 18.419277), ('zeroed_count', 0)])), ('train', OrderedDict([('sparse_categorical_accuracy', 0.161214), ('loss', 2.2744186)])), ('stat', OrderedDict([('num_examples', 9720)]))])
...

How do I keep track of the privacy spent by each client in every round and the total privacy spend by each client at the end of training? I would appreciate a code example.

@ZacharyGarrett
Copy link
Collaborator

@galenmandrew might you be able to provide some guidance here?

IIRC, the state object is keeping a ledger throughout training. Passing is to an API tensorflow_privacy (https://github.com/tensorflow/privacy) may allow computing the final accounting?

@galenmandrew
Copy link
Contributor

Performing privacy accounting in sync with training is not yet implemented, but since you have a constant noise_multiplier and clients_per_round you can easily compute the privacy spent at each round using the methods in tensorflow_privacy/privacy/accounting. For a code example, see the tensorflow_privacy tutorial here.

Note that while you asked for "privacy spent by each client", what the tensorflow_privacy code computes is the total privacy, or the worst case privacy over clients. It is not possible to compute the actual privacy spent by each client because the set of clients that participate in each round is private!

@cozek
Copy link
Author
cozek commented May 7, 2021

Thanks you both for the answers and clarification. I appreciate it. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants