Building-ML-Pipelines / building-machine-learning-pipelines

Code repository for the O'Reilly publication "Building Machine Learning Pipelines" by Hannes Hapke & Catherine Nelson
MIT License
584 stars 249 forks source link

Differential Privacy - Fix for differentially private optimizer not called #32

Closed mshearer0 closed 2 years ago

mshearer0 commented 4 years ago

model.fit produces:

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+.

Using modified optimiser here allowed fit to complete.

hanneshapke commented 4 years ago

Hi @mshearer0,

I have made some tweaks to the example a few days ago. It requires tf-nightly. Feel free to check out the example branch: https://github.com/Building-ML-Pipelines/building-machine-learning-pipelines/tree/updated-privacy-example

mshearer0 commented 4 years ago

Hi Hannes, yes I spotted that and used the new version from the pull request branch but got the same error. Using the modified optimiser works ok