Commit graph

787 commits

Author SHA1 Message Date
A. Unique TensorFlower
3f6d0acdef Add ability to use sample weights to the membership attack models, where they are supported by the underlying Scikit-Learn estimators. Only the Logistic Regression and Random Forest estimators support sample weights.
PiperOrigin-RevId: 478542133
2022-10-03 10:32:31 -07:00
Michael Reneer
feddd28a63 Pin tensorflow-probability to a specific version.
This matches the documentation for specifying version for this project. Additionally, recent version of `tensorflow-probability` are releasing breaking changes and the existing version specifier allows these to breaking changes to be unintentionally pulled in.

PiperOrigin-RevId: 476443999
2022-09-23 13:04:47 -07:00
Chen Qian
c6c3334b57 Code changes to get ready for an incoming Keras optimizer migration.
DP optimizer only supports legacy optimizer.

PiperOrigin-RevId: 474137890
2022-09-13 15:20:26 -07:00
Shuang Song
08364adcb7 Allow squared loss to take in labels and predictions of the same number of elements but different shapes.
PiperOrigin-RevId: 474059427
2022-09-13 10:32:58 -07:00
Yilei Yang
ebae6c086e Make this code compatible with Python 3.10.
PiperOrigin-RevId: 473313795
2022-09-09 12:20:05 -07:00
Chen Qian
715fd1a670 Code changes to get ready for an incoming Keras optimizer migration.
Because the code subclasses the legacy Keras optimizer, we should explicitly use the legacy optimizer.

PiperOrigin-RevId: 473092233
2022-09-08 14:56:56 -07:00
Steve Chien
407e5c8e11 Clarify logic in Keras version of DP-SGD optimizer, and add a unit test involving clipping on multiple variables.
PiperOrigin-RevId: 472559697
2022-09-06 14:36:43 -07:00
Michael Reneer
628e5bb926 Update the setup.py to match the requirements.txt.
PiperOrigin-RevId: 471128177
2022-08-30 17:16:42 -07:00
Steve Chien
ed73077b60 Change version to 0.8.5. (Previously incorrectly skipped ahead to 0.8.6)
PiperOrigin-RevId: 471118348
2022-08-30 16:28:14 -07:00
Steve Chien
875b7f46bd Automated rollback of commit cff47686f6
PiperOrigin-RevId: 471104040
2022-08-30 15:23:08 -07:00
A. Unique TensorFlower
cff47686f6 Changes DPOptimizerClass to generically accept and use any dp_sum_query.
This enables creation of generic DPOptimizers by user's passing queries. The most common Gaussian query is automatically performed for convenience and backwards compatibility.

Byproducts of this update:
-ensures consistent implementations between the internal (and legacy) `get_gradients` and newer `_compute_gradients` for all queries.
-refactors for python readability.

PiperOrigin-RevId: 470883774
2022-08-29 20:22:40 -07:00
Steve Chien
ed16033a92 Update pinned commit of dp-accounting library, update dependency versions, and increase version to 0.8.6.
PiperOrigin-RevId: 470334560
2022-08-26 14:30:16 -07:00
Shuang Song
9f4feade7d Add more documentation for gradient_accumulation_steps in keras optimizer.
PiperOrigin-RevId: 469310667
2022-08-22 16:16:46 -07:00
Steve Chien
9e25eee68b Update remaining DPQuery tests to TF2.
PiperOrigin-RevId: 468793518
2022-08-19 15:08:15 -07:00
Steve Chien
fd64be5b5b Update several DPQuery tests to TF v2.
PiperOrigin-RevId: 468763153
2022-08-19 12:40:49 -07:00
Galen Andrew
7fe491f7a4 Update the conventions used to specify the version of a Python dependency.
* For packages that have a stable release, we use a version that is compatible with that release (e.g. `~=x.y`).
* For packages that do not have a stable release, we use a version that matches a release that has been tested (e.g. `==x.y.z`).

Additionally, added documentation to the requirements.txt.

PiperOrigin-RevId: 468720651
2022-08-19 09:38:19 -07:00
Steve Chien
d6ad59226d Update tests for optimizer classes to TF 2.
PiperOrigin-RevId: 468587323
2022-08-18 17:38:01 -07:00
Steve Chien
5dd11fcdd6 Add import of log_loss in keras_evaluation.py.
PiperOrigin-RevId: 468294581
2022-08-17 14:31:20 -07:00
Michael Reneer
052f9a3128 Update the version of numpy to 1.23.2.
* Updated the numpy version.
* Synced the pandas version.

In Python 3.10, if you invoke `pip install pandas~=1.1.4 numpy~=1.21.4` and then `import pandas` you get the following error:

```
>>> import pandas
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tmp/venv/lib/python3.10/site-packages/pandas/__init__.py", line 30, in <module>
    from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib
  File "/tmp/venv/lib/python3.10/site-packages/pandas/_libs/__init__.py", line 13, in <module>
    from pandas._libs.interval import Interval
  File "pandas/_libs/interval.pyx", line 1, in init pandas._libs.interval
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject
```

I believe that this is the cause of the issue https://github.com/scikit-learn-contrib/hdbscan/issues/457#issuecomment-773671043

PiperOrigin-RevId: 467952859
2022-08-16 10:02:07 -07:00
Shuang Song
40d73ed240 Add logging for secret sharer exposure computation.
PiperOrigin-RevId: 467771239
2022-08-15 15:06:42 -07:00
Galen Andrew
8a449aaa27 Correct discrepancy between tensorflow-probability versions in requirements.txt vs setup.py.
PiperOrigin-RevId: 467326193
2022-08-12 17:04:55 -07:00
Galen Andrew
5a9866726d Change requirements for tensorflow-probability and pandas.
PiperOrigin-RevId: 467220343
2022-08-12 08:58:14 -07:00
Galen Andrew
ca077a5b12 Use calibrate_dp_mechanism from differential_privacy library instead of custom binary search.
PiperOrigin-RevId: 466798182
2022-08-10 15:19:44 -07:00
Peter Hawkins
857fe8f482 [NumPy] Replace numpy.asscalar(x) with x.item() in preparation for upgrading NumPy to 1.23.
NumPy 1.23 removes numpy.asscalar() (https://numpy.org/doc/stable/release/1.23.0-notes.html#expired-deprecations), which has been deprecated since NumPy 1.16 (https://numpy.org/doc/stable/release/1.16.0-notes.html#new-deprecations).

x.item() should be identical to the previous implementation of numpy.asscalar(x) in every way.

PiperOrigin-RevId: 466743223
2022-08-10 11:27:07 -07:00
Jake VanderPlas
6718ae2636 Rename jax.experimental.optimizers -> jax.example_libraries.optimizers
Why? The former name has been deprecated since JAX version 0.2.25, released in November 2021 (see https://github.com/google/jax/blob/main/CHANGELOG.md#jax-0225-nov-10-2021), and will soon be removed.

PiperOrigin-RevId: 465670868
2022-08-05 16:24:49 -07:00
Shuang Song
a9abfbc244 Allow specifying loss function with string.
PiperOrigin-RevId: 465333272
2022-08-04 09:31:28 -07:00
Steve Chien
a8a5206841 Update TFP to version 0.8.2.
PiperOrigin-RevId: 463664333
2022-07-27 13:29:15 -07:00
Steve Chien
848cfc74c1 Add logistic regression functions to API.
PiperOrigin-RevId: 463645193
2022-07-27 12:05:06 -07:00
Shuang Song
17cd0c52bc Refactor: move loss computation utilities under privacy_tests.
PiperOrigin-RevId: 463391913
2022-07-26 11:49:40 -07:00
Shuang Song
44dc40454b Minor fix to tutorials.
PiperOrigin-RevId: 463145196
2022-07-25 12:07:46 -07:00
Michael Reneer
d16f020329 Fix usage of logging API.
PiperOrigin-RevId: 463123944
2022-07-25 10:48:31 -07:00
Galen Andrew
4cb0a11c4b Automated rollback of commit db292fc5d8
PiperOrigin-RevId: 462171425
2022-07-20 10:16:48 -07:00
Steve Chien
38fe4aa984 Changes to prepare for release of v0.8.1.
Update WORKSPACE, setup.py, and requirements.txt to latest dp-accounting library release.

Update scipy version in setup.py.

Update version to 0.8.1.

PiperOrigin-RevId: 461944491
2022-07-19 12:22:07 -07:00
A. Unique TensorFlower
2b5d5b6ef5 Add Positive Predictive Value as a metric for membership attack models performance on imbalanced data.
PiperOrigin-RevId: 461390184
2022-07-16 16:30:53 -07:00
Shuang Song
328795aa36 Add assert that the training is private for TF1 vectorized optimizer.
In Keras training in TF 2.0+, compute_gradients() is not called but apply_gradients() is called. W/o calling compute_gradients() dp gradient is not computed, and a normal gradient is used.

PiperOrigin-RevId: 461021412
2022-07-14 12:15:00 -07:00
Michael Reneer
64c6b5ea25 Revert scipy dependency.
PiperOrigin-RevId: 460957101
2022-07-14 07:45:03 -07:00
A. Unique TensorFlower
1d002aa49c Increment the differential privacy accounting Bazel dependency to a version that supports mechanism calibration.
PiperOrigin-RevId: 460539211
2022-07-12 13:29:27 -07:00
A. Unique TensorFlower
e826ec717a Switch from a git_repository rule to http_archive for the DP accounting Bazel dependency. This is preferred, per https://docs.bazel.build/versions/main/external.html#repository-rules, to avoid depending on the system git (the HTTP downloader is build into Bazel).
Also use the strip_prefix option to only pull in the accounting WORKSPACE, not the top-level Google DP project WORKSPACE. This allows us to align the import statements to work both when pulling in the `dp_acounting` dependency via Bazel and pip.

PiperOrigin-RevId: 459807060
2022-07-08 12:07:17 -07:00
Michael Reneer
8b698a7fea Update build_pip_package script to use the built in Python virtual environment tool.
See https://docs.python.org/3/library/venv.html for more information

PiperOrigin-RevId: 459806458
2022-07-08 12:05:21 -07:00
Michael Reneer
27c07fa7b8 Update the TFP requirements.
PiperOrigin-RevId: 459806353
2022-07-08 12:04:04 -07:00
A. Unique TensorFlower
eaa7354f00 Internal change.
PiperOrigin-RevId: 459620579
2022-07-07 15:48:25 -07:00
Steve Chien
24f80e8c76 Increase scipy version to 1.7.1.
PiperOrigin-RevId: 459371512
2022-07-06 16:27:01 -07:00
Michael Reneer
94beccf10e Automated rollback of commit e32766cc73
PiperOrigin-RevId: 458498524
2022-07-01 10:34:33 -07:00
A. Unique TensorFlower
e32766cc73 Automated rollback of commit b16a0abf1c
PiperOrigin-RevId: 458478847
2022-07-01 08:52:40 -07:00
Michael Reneer
b16a0abf1c Update TFPs dp_accounting dependency.
PiperOrigin-RevId: 458307242
2022-06-30 13:57:42 -07:00
Galen Andrew
22b92a61ca Update to newest commit of differential_privacy.
PiperOrigin-RevId: 458275483
2022-06-30 11:39:08 -07:00
A. Unique TensorFlower
c665281c55 Implementation of Differentially Private Logistic Regression.
PiperOrigin-RevId: 458266079
2022-06-30 11:01:02 -07:00
Galen Andrew
77d962e0fc Use DP library's calibrate_dp_mechanism function to compute noise multiplier.
calibrate_dp_mechanism is in dp_accounting's top level symbols, so after this change we can replace all of the dependencies on DP accounting subpackages with dp_accounting.

Tested by verifying that the resulting noise multiplier is the same before and after change when running all tests in multinomial_logistic_test.

PiperOrigin-RevId: 458235745
2022-06-30 08:47:54 -07:00
Markus Kunesch
9383743252 Update attrs dependency in requirements.txt to match setup.py.
PiperOrigin-RevId: 456986050
2022-06-24 04:59:18 -07:00
Michael Reneer
adce0fdfc0 Update TFPs attrs dependency to version 21.4.0.
PiperOrigin-RevId: 455655859
2022-06-17 11:09:29 -07:00