# TensorFlow Privacy
This repository contains the source code for TensorFlow Privacy, a Python
library that includes implementations of TensorFlow optimizers for training
machine learning models with differential privacy. The library comes with
tutorials and analysis tools for computing the privacy guarantees provided.
The TensorFlow Privacy library is under continual development, always welcoming
contributions. In particular, we always welcome help towards resolving the
issues currently open.
## Latest Updates
2023-02-21: A new implementation of efficient per-example gradient clipping is
now available for
[DP keras models](https://github.com/tensorflow/privacy/tree/master/tensorflow_privacy/privacy/keras_models)
consisting only of Dense and Embedding layers. The models use the fast gradient
calculation results of [this paper](https://arxiv.org/abs/1510.01799). The
implementation should allow for doing DP training without any meaningful memory
or runtime overhead. It also removes the need for tuning the number of
microbatches as it clips the gradient with respect to each example.
## Setting up TensorFlow Privacy
### Dependencies
This library uses [TensorFlow](https://www.tensorflow.org/) to define machine
learning models. Therefore, installing TensorFlow (>= 1.14) is a pre-requisite.
You can find instructions [here](https://www.tensorflow.org/install/). For
better performance, it is also recommended to install TensorFlow with GPU
support (detailed instructions on how to do this are available in the TensorFlow
installation documentation).
In addition to TensorFlow and its dependencies, other prerequisites are:
* `scipy` >= 0.17
* `mpmath` (for testing)
* `tensorflow_datasets` (for the RNN tutorial `lm_dpsgd_tutorial.py` only)
### Installing TensorFlow Privacy
If you only want to use TensorFlow Privacy as a library, you can simply execute
`pip install tensorflow-privacy`
Otherwise, you can clone this GitHub repository into a directory of your choice:
```
git clone https://github.com/tensorflow/privacy
```
You can then install the local package in "editable" mode in order to add it to
your `PYTHONPATH`:
```
cd privacy
pip install -e .
```
If you'd like to make contributions, we recommend first forking the repository
and then cloning your fork rather than cloning this repository directly.
## Contributing
Contributions are welcomed! Bug fixes and new features can be initiated through
GitHub pull requests. To speed the code review process, we ask that:
* When making code contributions to TensorFlow Privacy, you follow the `PEP8
with two spaces` coding style (the same as the one used by TensorFlow) in
your pull requests. In most cases this can be done by running `autopep8 -i
--indent-size 2 <file>` on the files you have edited.
* You should also check your code with pylint and TensorFlow's pylint
[configuration file](https://raw.githubusercontent.com/tensorflow/tensorflow/master/tensorflow/tools/ci_build/pylintrc)
by running `pylint --rcfile=/path/to/the/tf/rcfile <edited file.py>`.
* When making your first pull request, you
[sign the Google CLA](https://cla.developers.google.com/clas)
* We do not accept pull requests that add git submodules because of
[the problems that arise when maintaining git submodules](https://medium.com/@porteneuve/mastering-git-submodules-34c65e940407)
## Tutorials directory
To help you get started with the functionalities provided by this library, we
provide a detailed walkthrough [here](tutorials/walkthrough/README.md) that will
teach you how to wrap existing optimizers (e.g., SGD, Adam, ...) into their
differentially private counterparts using TensorFlow (TF) Privacy. You will also
learn how to tune the parameters introduced by differentially private
optimization and how to measure the privacy guarantees provided using analysis
tools included in TF Privacy.
In addition, the `tutorials/` folder comes with scripts demonstrating how to use
the library features. The list of tutorials is described in the README included
in the tutorials directory.
NOTE: the tutorials are maintained carefully. However, they are not considered
part of the API and they can change at any time without warning. You should not
write 3rd party code that imports the tutorials and expect that the interface
will not break.
## Research directory
This folder contains code to reproduce results from research papers related to
privacy in machine learning. It is not maintained as carefully as the tutorials
directory, but rather intended as a convenient archive.
## TensorFlow 2.x
TensorFlow Privacy now works with TensorFlow 2! You can use the new Keras-based
estimators found in
`privacy/tensorflow_privacy/privacy/optimizers/dp_optimizer_keras.py`.
For this to work with `tf.keras.Model` and `tf.estimator.Estimator`, however,
you need to install TensorFlow 2.4 or later.
## Remarks
The content of this repository supersedes the following existing folder in the
tensorflow/models
[repository](https://github.com/tensorflow/models/tree/master/research/differential_privacy)
## Contacts
If you have any questions that cannot be addressed by raising an issue, feel
free to contact:
* Galen Andrew (@galenmandrew)
* Steve Chien (@schien1729)
* Nicolas Papernot (@npapernot)
## Copyright
Copyright 2019 - Google LLC
没有合适的资源?快使用搜索试试~ 我知道了~
tensorflow_privacy-0.8.11.tar.gz
0 下载量 153 浏览量
2024-03-28
23:54:44
上传
评论
收藏 240KB GZ 举报
温馨提示
共183个文件
py:174个
txt:4个
pkg-info:2个
Python库是一组预先编写的代码模块,旨在帮助开发者实现特定的编程任务,无需从零开始编写代码。这些库可以包括各种功能,如数学运算、文件操作、数据分析和网络编程等。Python社区提供了大量的第三方库,如NumPy、Pandas和Requests,极大地丰富了Python的应用领域,从数据科学到Web开发。Python库的丰富性是Python成为最受欢迎的编程语言之一的关键原因之一。这些库不仅为初学者提供了快速入门的途径,而且为经验丰富的开发者提供了强大的工具,以高效率、高质量地完成复杂任务。例如,Matplotlib和Seaborn库在数据可视化领域内非常受欢迎,它们提供了广泛的工具和技术,可以创建高度定制化的图表和图形,帮助数据科学家和分析师在数据探索和结果展示中更有效地传达信息。
资源推荐
资源详情
资源评论
收起资源包目录
tensorflow_privacy-0.8.11.tar.gz (183个子文件)
setup.cfg 38B
LICENSE 12KB
README.md 5KB
PKG-INFO 761B
PKG-INFO 761B
data_structures.py 51KB
dp_optimizer_keras_test.py 43KB
data_structures_test.py 43KB
dp_optimizer_keras.py 26KB
membership_inference_attack.py 23KB
membership_inference_attack_test.py 22KB
tree_aggregation_query.py 22KB
tree_aggregation.py 21KB
head.py 20KB
tree_aggregation_query_test.py 20KB
dp_optimizer_keras_sparse_test.py 20KB
dataset_slicing_test.py 19KB
quantile_adaptive_clip_tree_query_test.py 19KB
optimizers_test.py 18KB
tree_aggregation_test.py 18KB
dp_optimizer_keras_sparse.py 18KB
compute_dp_sgd_privacy_lib.py 16KB
tree_aggregation_accountant.py 16KB
dp_optimizer_test.py 16KB
dp_optimizer.py 16KB
models_test.py 16KB
common_test_utils.py 15KB
clip_grads.py 14KB
epsilon_lower_bound.py 14KB
dp_keras_model_test.py 14KB
losses_test.py 14KB
optimizers.py 14KB
dp_keras_model.py 13KB
utils_test.py 13KB
einsum_utils.py 13KB
quantile_estimator_query_test.py 12KB
dataset_slicing.py 12KB
dp_query.py 12KB
advanced_mia_test.py 11KB
models.py 11KB
advanced_mia.py 11KB
seq2seq_mia.py 11KB
tree_range_query.py 11KB
models.py 11KB
epsilon_lower_bound_test.py 11KB
quantile_adaptive_clip_sum_query_test.py 11KB
utils.py 11KB
quantile_estimator_query.py 11KB
tf_estimator_evaluation.py 11KB
privacy_report_test.py 10KB
dp_optimizer_keras_vectorized.py 10KB
compute_dp_sgd_privacy_test.py 10KB
seq2seq_mia_test.py 10KB
multinomial_logistic.py 10KB
losses.py 10KB
clip_and_aggregate_gradients.py 10KB
einsum_utils_test.py 10KB
advanced_mia_example.py 10KB
clip_and_aggregate_gradients_test.py 10KB
gradient_clipping_utils.py 9KB
dp_optimizer_vectorized_test.py 9KB
quantile_adaptive_clip_tree_query.py 9KB
dp_optimizer_vectorized.py 8KB
tree_aggregation_accountant_test.py 8KB
discrete_gaussian_utils_test.py 8KB
tree_range_query_test.py 8KB
restart_query_test.py 8KB
clip_grads_test.py 7KB
restart_query.py 7KB
distributed_discrete_gaussian_query_test.py 7KB
tf_estimator_evaluation_test.py 7KB
nested_query_test.py 7KB
distributed_skellam_query.py 7KB
quantile_adaptive_clip_sum_query.py 7KB
tf_estimator_evaluation_example.py 6KB
keras_evaluation.py 6KB
multi_label_head.py 6KB
dp_keras_model_distributed_test.py 6KB
binary_class_head.py 6KB
distributed_skellam_query_test.py 6KB
gradient_clipping_utils_test.py 6KB
multi_class_head.py 6KB
discrete_gaussian_query_test.py 6KB
generate_secrets.py 6KB
privacy_report.py 6KB
models_test.py 6KB
__init__.py 6KB
nested_query.py 6KB
discrete_gaussian_utils.py 5KB
embedding_test.py 5KB
dp_optimizer_keras_sparse_distributed_test.py 5KB
layer_normalization_test.py 5KB
registry_function_utils.py 5KB
dense_test.py 5KB
datasets.py 5KB
nlp_on_device_embedding_test.py 5KB
nlp_position_embedding_test.py 5KB
tensor_buffer.py 5KB
dp_optimizer_eager_test.py 5KB
distributed_discrete_gaussian_query.py 4KB
共 183 条
- 1
- 2
资源评论
程序员Chino的日记
- 粉丝: 2861
- 资源: 4万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功