tensorflow / tensorflow/privacy

DPKeras optimizer fails when num_microbatches is None (default)

Open
#155 0 comments 0 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

Hi,

first of all, thanks for continuing to expand and improve this amazing repo. I've noticed a small issue with the usage of the new DPKeras* optimizers (the non vectorized version). Running with the default num_microbatches=None gives the following error:

TypeError: Failed to convert object of type <class 'list'> to Tensor. Contents: [None, -1]. Consider casting elements to a supported type.

I think that this is due to the fact that self._num_microbatches is assigned the input value None. All other DP optimizers (vectorized keras ones included) contains a check for this situation (here, for example), which updates a None self._num_microbatches to the right value. This check is missing in dp_optimizer_keras, hence the error.

thanks a lot,
Matteo

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 by inspecting the non-vectorized DPKeras optimizer implementation in dp_optimizer_keras and compare its handling of num_microbatches with the referenced dp_optimizer.py check. Verify the default num_microbatches=None path no longer produces the reported TypeError and confirm existing optimizer behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, tensorflow
Domain
machine-learning
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.