Add TensorFlow Privacy BUILD and WORKSPACE files.

PiperOrigin-RevId: 429141704
This commit is contained in:
Michael Reneer 2022-02-16 22:31:34 +00:00
parent 2d692bbf73
commit 69d84d1892
28 changed files with 1505 additions and 1 deletions

20
.bazelrc Normal file
View file

@ -0,0 +1,20 @@
# TensorFlow Privacy Bazel configuration
#
# See https://docs.bazel.build/versions/master/user-manual.html#config for
# details on the various configuration options.
# Enable verbose failures.
build --verbose_failures
# Enable logging rc options.
common --announce_rc
# Enable platform-specific configs from bazelrc files.
common --enable_platform_specific_config
# Enable logging error output.
test --test_output=errors
test --test_summary=detailed
# Execute commands as local subprocesses
build --spawn_strategy=local

5
BUILD Normal file
View file

@ -0,0 +1,5 @@
package(default_visibility = ["//visibility:private"])
licenses(["notice"])
exports_files(["LICENSE"])

15
WORKSPACE Normal file
View file

@ -0,0 +1,15 @@
workspace(name = "org_tensorflow_privacy")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
git_repository(
name = "bazel_skylib",
remote = "https://github.com/bazelbuild/bazel-skylib.git",
tag = "1.0.3",
)
git_repository(
name = "rules_python",
remote = "https://github.com/bazelbuild/rules_python.git",
tag = "0.5.0",
)

18
g3doc/BUILD Normal file
View file

@ -0,0 +1,18 @@
load("@rules_python//python:defs.bzl", "py_binary")
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
py_binary(
name = "build_docs",
srcs = ["build_docs.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
"//tensorflow_privacy",
"//third_party/py/tensorflow_docs/api_generator:doc_controls",
"//third_party/py/tensorflow_docs/api_generator:generate_lib",
"//third_party/py/tensorflow_docs/api_generator:public_api",
],
)

12
research/GDP_2019/BUILD Normal file
View file

@ -0,0 +1,12 @@
package(default_visibility = ["//visibility:private"])
licenses(["notice"])
filegroup(
name = "ignore_srcs",
srcs = [
"adult_tutorial.py",
"imdb_tutorial.py",
],
tags = ["ignore_srcs"],
)

18
research/pate_2017/BUILD Normal file
View file

@ -0,0 +1,18 @@
package(default_visibility = ["//visibility:private"])
licenses(["notice"])
filegroup(
name = "ignore_srcs",
srcs = [
"aggregation.py",
"analysis.py",
"deep_cnn.py",
"input.py",
"metrics.py",
"train_student.py",
"train_teachers.py",
"utils.py",
],
tags = ["ignore_srcs"],
)

14
research/pate_2018/BUILD Normal file
View file

@ -0,0 +1,14 @@
package(default_visibility = ["//visibility:private"])
licenses(["notice"])
filegroup(
name = "ignore_srcs",
srcs = [
"core.py",
"core_test.py",
"smooth_sensitivity.py",
"smooth_sensitivity_test.py",
],
tags = ["ignore_srcs"],
)

View file

@ -0,0 +1,18 @@
package(default_visibility = ["//visibility:private"])
licenses(["notice"])
filegroup(
name = "ignore_srcs",
srcs = [
"download.py",
"plot_ls_q.py",
"plot_partition.py",
"plots_for_slides.py",
"rdp_bucketized.py",
"rdp_cumulative.py",
"smooth_sensitivity_table.py",
"utility_queries_answered.py",
],
tags = ["ignore_srcs"],
)

57
tensorflow_privacy/BUILD Normal file
View file

@ -0,0 +1,57 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@rules_python//python:defs.bzl", "py_library")
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
exports_files([
"LICENSE",
])
py_library(
name = "tensorflow_privacy",
srcs = ["__init__.py"],
srcs_version = "PY3",
deps = [
":version",
"//tensorflow_privacy/privacy/analysis:compute_dp_sgd_privacy_lib",
"//tensorflow_privacy/privacy/analysis:dp_event",
"//tensorflow_privacy/privacy/analysis:rdp_accountant",
"//tensorflow_privacy/privacy/analysis:tree_aggregation_accountant",
"//tensorflow_privacy/privacy/dp_query",
"//tensorflow_privacy/privacy/dp_query:discrete_gaussian_query",
"//tensorflow_privacy/privacy/dp_query:distributed_discrete_gaussian_query",
"//tensorflow_privacy/privacy/dp_query:gaussian_query",
"//tensorflow_privacy/privacy/dp_query:nested_query",
"//tensorflow_privacy/privacy/dp_query:no_privacy_query",
"//tensorflow_privacy/privacy/dp_query:normalized_query",
"//tensorflow_privacy/privacy/dp_query:quantile_adaptive_clip_sum_query",
"//tensorflow_privacy/privacy/dp_query:quantile_estimator_query",
"//tensorflow_privacy/privacy/dp_query:restart_query",
"//tensorflow_privacy/privacy/dp_query:tree_aggregation",
"//tensorflow_privacy/privacy/dp_query:tree_aggregation_query",
"//tensorflow_privacy/privacy/dp_query:tree_range_query",
"//tensorflow_privacy/privacy/estimators:dnn",
"//tensorflow_privacy/privacy/keras_models:dp_keras_model",
"//tensorflow_privacy/privacy/optimizers:dp_optimizer_keras",
"//tensorflow_privacy/privacy/optimizers:dp_optimizer_keras_vectorized",
"//tensorflow_privacy/v1:tensorflow_privacy_v1",
],
)
build_test(
name = "tensorflow_privacy_build_test",
targets = [":tensorflow_privacy"],
)
py_library(
name = "version",
srcs = ["version.py"],
srcs_version = "PY3",
)
filegroup(
name = "ignore_srcs",
tags = ["ignore_srcs"],
)

View file

@ -1 +0,0 @@
workspace(name = "org_tensorflow_privacy")

View file

@ -0,0 +1,10 @@
load("@rules_python//python:defs.bzl", "py_library")
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
py_library(
name = "privacy",
srcs = ["__init__.py"],
)

View file

@ -0,0 +1,182 @@
load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
py_library(
name = "analysis",
srcs = ["__init__.py"],
)
py_library(
name = "compute_dp_sgd_privacy_lib",
srcs = ["compute_dp_sgd_privacy_lib.py"],
srcs_version = "PY3",
deps = [":rdp_accountant"],
)
py_binary(
name = "compute_dp_sgd_privacy",
srcs = ["compute_dp_sgd_privacy.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [":compute_dp_sgd_privacy_lib"],
)
py_test(
name = "compute_dp_sgd_privacy_test",
size = "small",
srcs = ["compute_dp_sgd_privacy_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [":compute_dp_sgd_privacy_lib"],
)
py_binary(
name = "compute_noise_from_budget",
srcs = ["compute_noise_from_budget.py"],
deps = [":compute_noise_from_budget_lib"],
)
py_library(
name = "compute_noise_from_budget_lib",
srcs = ["compute_noise_from_budget_lib.py"],
deps = [":rdp_accountant"],
)
py_test(
name = "compute_noise_from_budget_test",
srcs = ["compute_noise_from_budget_test.py"],
deps = [":compute_noise_from_budget_lib"],
)
py_library(
name = "dp_event",
srcs = ["dp_event.py"],
srcs_version = "PY3",
)
py_library(
name = "dp_event_builder",
srcs = ["dp_event_builder.py"],
srcs_version = "PY3",
deps = [":dp_event"],
)
py_test(
name = "dp_event_builder_test",
srcs = ["dp_event_builder_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":dp_event",
":dp_event_builder",
],
)
py_library(
name = "gdp_accountant",
srcs = ["gdp_accountant.py"],
)
py_library(
name = "privacy_accountant",
srcs = ["privacy_accountant.py"],
srcs_version = "PY3",
deps = [
":dp_event",
":dp_event_builder",
],
)
py_library(
name = "privacy_accountant_test",
srcs = ["privacy_accountant_test.py"],
srcs_version = "PY3",
deps = [
":dp_event",
":privacy_accountant",
],
)
py_library(
name = "rdp_accountant",
srcs = ["rdp_accountant.py"],
srcs_version = "PY3",
visibility = ["//visibility:public"],
)
py_test(
name = "rdp_accountant_test",
size = "small",
srcs = ["rdp_accountant_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [":rdp_accountant"],
)
py_library(
name = "rdp_privacy_accountant",
srcs = ["rdp_privacy_accountant.py"],
srcs_version = "PY3",
deps = [
":dp_event",
":privacy_accountant",
],
)
py_test(
name = "rdp_privacy_accountant_test",
size = "small",
srcs = ["rdp_privacy_accountant_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":dp_event",
":privacy_accountant",
":privacy_accountant_test",
":rdp_privacy_accountant",
],
)
py_library(
name = "tensor_buffer",
srcs = ["tensor_buffer.py"],
srcs_version = "PY3",
)
py_test(
name = "tensor_buffer_eager_test",
size = "small",
srcs = ["tensor_buffer_eager_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [":tensor_buffer"],
)
py_test(
name = "tensor_buffer_graph_test",
size = "small",
srcs = ["tensor_buffer_graph_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [":tensor_buffer"],
)
py_library(
name = "tree_aggregation_accountant",
srcs = ["tree_aggregation_accountant.py"],
srcs_version = "PY3",
)
py_test(
name = "tree_aggregation_accountant_test",
srcs = ["tree_aggregation_accountant_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":rdp_accountant",
":tree_aggregation_accountant",
],
)

View file

@ -0,0 +1,17 @@
package(default_visibility = ["//visibility:private"])
licenses(["notice"])
filegroup(
name = "ignore_srcs",
srcs = [
"__init__.py",
"losses.py",
"losses_test.py",
"models.py",
"models_test.py",
"optimizers.py",
"optimizers_test.py",
],
tags = ["ignore_srcs"],
)

View file

@ -0,0 +1,295 @@
load("@rules_python//python:defs.bzl", "py_library", "py_test")
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
py_library(
name = "__init__", # There is already a dp_query.
srcs = ["__init__.py"],
)
py_library(
name = "dp_query",
srcs = ["dp_query.py"],
srcs_version = "PY3",
)
py_library(
name = "discrete_gaussian_utils",
srcs = ["discrete_gaussian_utils.py"],
srcs_version = "PY3",
)
py_test(
name = "discrete_gaussian_utils_test",
srcs = ["discrete_gaussian_utils_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [":discrete_gaussian_utils"],
)
py_library(
name = "discrete_gaussian_query",
srcs = ["discrete_gaussian_query.py"],
srcs_version = "PY3",
deps = [
":discrete_gaussian_utils",
":dp_query",
"//tensorflow_privacy/privacy/analysis:dp_event",
],
)
py_test(
name = "discrete_gaussian_query_test",
srcs = ["discrete_gaussian_query_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":discrete_gaussian_query",
":discrete_gaussian_utils",
":test_utils",
],
)
py_library(
name = "distributed_discrete_gaussian_query",
srcs = ["distributed_discrete_gaussian_query.py"],
srcs_version = "PY3",
deps = [
":discrete_gaussian_utils",
":dp_query",
"//tensorflow_privacy/privacy/analysis:dp_event",
],
)
py_test(
name = "distributed_discrete_gaussian_query_test",
srcs = ["distributed_discrete_gaussian_query_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":discrete_gaussian_utils",
":distributed_discrete_gaussian_query",
":test_utils",
],
)
py_library(
name = "gaussian_query",
srcs = ["gaussian_query.py"],
srcs_version = "PY3",
deps = [
":dp_query",
"//tensorflow_privacy/privacy/analysis:dp_event",
],
)
py_test(
name = "gaussian_query_test",
size = "small",
srcs = ["gaussian_query_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":gaussian_query",
":test_utils",
],
)
py_library(
name = "no_privacy_query",
srcs = ["no_privacy_query.py"],
srcs_version = "PY3",
deps = [
":dp_query",
"//tensorflow_privacy/privacy/analysis:dp_event",
],
)
py_test(
name = "no_privacy_query_test",
size = "small",
srcs = ["no_privacy_query_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":no_privacy_query",
":test_utils",
],
)
py_library(
name = "normalized_query",
srcs = ["normalized_query.py"],
srcs_version = "PY3",
deps = [":dp_query"],
)
py_test(
name = "normalized_query_test",
size = "small",
srcs = ["normalized_query_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":gaussian_query",
":normalized_query",
":test_utils",
],
)
py_library(
name = "nested_query",
srcs = ["nested_query.py"],
srcs_version = "PY3",
deps = [
":dp_query",
"//tensorflow_privacy/privacy/analysis:dp_event",
],
)
py_test(
name = "nested_query_test",
size = "small",
srcs = ["nested_query_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":dp_query",
":gaussian_query",
":nested_query",
":normalized_query",
":test_utils",
],
)
py_library(
name = "quantile_adaptive_clip_sum_query",
srcs = ["quantile_adaptive_clip_sum_query.py"],
srcs_version = "PY3",
deps = [
":dp_query",
":gaussian_query",
":quantile_estimator_query",
"//tensorflow_privacy/privacy/analysis:dp_event",
],
)
py_test(
name = "quantile_adaptive_clip_sum_query_test",
srcs = ["quantile_adaptive_clip_sum_query_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":quantile_adaptive_clip_sum_query",
":test_utils",
],
)
py_library(
name = "quantile_estimator_query",
srcs = ["quantile_estimator_query.py"],
srcs_version = "PY3",
deps = [
":dp_query",
":gaussian_query",
":no_privacy_query",
":normalized_query",
":tree_aggregation_query",
],
)
py_test(
name = "quantile_estimator_query_test",
srcs = ["quantile_estimator_query_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":quantile_estimator_query",
":test_utils",
],
)
py_library(
name = "test_utils",
srcs = ["test_utils.py"],
srcs_version = "PY3",
)
py_library(
name = "tree_aggregation",
srcs = ["tree_aggregation.py"],
srcs_version = "PY3",
)
py_test(
name = "tree_aggregation_test",
srcs = ["tree_aggregation_test.py"],
python_version = "PY3",
shard_count = 10,
srcs_version = "PY3",
deps = [":tree_aggregation"],
)
py_test(
name = "tree_aggregation_query_test",
srcs = ["tree_aggregation_query_test.py"],
python_version = "PY3",
shard_count = 5,
srcs_version = "PY3",
deps = [
":test_utils",
":tree_aggregation",
":tree_aggregation_query",
],
)
py_library(
name = "tree_aggregation_query",
srcs = ["tree_aggregation_query.py"],
srcs_version = "PY3",
deps = [
":dp_query",
":tree_aggregation",
"//tensorflow_privacy/privacy/analysis:dp_event",
],
)
py_library(
name = "tree_range_query",
srcs = ["tree_range_query.py"],
srcs_version = "PY3",
deps = [
":distributed_discrete_gaussian_query",
":dp_query",
":gaussian_query",
"//tensorflow_privacy/privacy/analysis:dp_event",
],
)
py_test(
name = "tree_range_query_test",
srcs = ["tree_range_query_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [":tree_range_query"],
)
py_test(
name = "restart_query_test",
srcs = ["restart_query_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":restart_query",
":tree_aggregation_query",
],
)
py_library(
name = "restart_query",
srcs = ["restart_query.py"],
srcs_version = "PY3",
deps = [":dp_query"],
)

View file

@ -0,0 +1,115 @@
load("@rules_python//python:defs.bzl", "py_library", "py_test")
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
py_library(
name = "estimators",
srcs = ["__init__.py"],
)
py_library(
name = "head_utils",
srcs = [
"head_utils.py",
],
srcs_version = "PY3",
deps = [
":binary_class_head",
":multi_class_head",
],
)
py_library(
name = "binary_class_head",
srcs = [
"binary_class_head.py",
],
srcs_version = "PY3",
)
py_library(
name = "multi_class_head",
srcs = [
"multi_class_head.py",
],
srcs_version = "PY3",
)
py_library(
name = "multi_label_head",
srcs = [
"multi_label_head.py",
],
srcs_version = "PY3",
)
py_library(
name = "dnn",
srcs = [
"dnn.py",
],
srcs_version = "PY3",
deps = [":head_utils"],
)
py_library(
name = "test_utils",
srcs = [
"test_utils.py",
],
srcs_version = "PY3",
)
py_test(
name = "binary_class_head_test",
timeout = "long",
srcs = ["binary_class_head_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":binary_class_head",
":test_utils",
"//tensorflow_privacy/privacy/optimizers:dp_optimizer_keras",
],
)
py_test(
name = "multi_class_head_test",
timeout = "long",
srcs = ["multi_class_head_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":multi_class_head",
":test_utils",
"//tensorflow_privacy/privacy/optimizers:dp_optimizer_keras",
],
)
py_test(
name = "multi_label_head_test",
timeout = "long",
srcs = ["multi_label_head_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":multi_label_head",
":test_utils",
"//tensorflow_privacy/privacy/optimizers:dp_optimizer_keras",
],
)
py_test(
name = "dnn_test",
timeout = "long",
srcs = ["dnn_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":dnn",
":test_utils",
"//tensorflow_privacy/privacy/optimizers:dp_optimizer_keras",
],
)

View file

@ -0,0 +1,53 @@
load("@rules_python//python:defs.bzl", "py_library", "py_test")
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
py_library(
name = "v1",
srcs = ["__init__.py"],
)
py_library(
name = "head",
srcs = [
"head.py",
],
srcs_version = "PY3",
)
py_library(
name = "dnn",
srcs = [
"dnn.py",
],
srcs_version = "PY3",
deps = [":head"],
)
py_test(
name = "head_test",
timeout = "long",
srcs = ["head_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":head",
"//tensorflow_privacy/privacy/estimators:test_utils",
"//tensorflow_privacy/privacy/optimizers:dp_optimizer",
],
)
py_test(
name = "dnn_test",
timeout = "long",
srcs = ["dnn_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":dnn",
"//tensorflow_privacy/privacy/estimators:test_utils",
"//tensorflow_privacy/privacy/optimizers:dp_optimizer",
],
)

View file

@ -0,0 +1,26 @@
load("@rules_python//python:defs.bzl", "py_library", "py_test")
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
py_library(
name = "keras_models",
srcs = ["__init__.py"],
)
py_library(
name = "dp_keras_model",
srcs = [
"dp_keras_model.py",
],
srcs_version = "PY3",
)
py_test(
name = "dp_keras_model_test",
srcs = ["dp_keras_model_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = ["//tensorflow_privacy/privacy/keras_models:dp_keras_model"],
)

View file

@ -0,0 +1,66 @@
load("@rules_python//python:defs.bzl", "py_library", "py_test")
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
py_library(
name = "multinomial_logistic",
srcs = ["multinomial_logistic.py"],
srcs_version = "PY3",
deps = [
":datasets",
":single_layer_softmax",
"//tensorflow_privacy/privacy/analysis:compute_dp_sgd_privacy_lib",
"//tensorflow_privacy/privacy/optimizers:dp_optimizer_keras",
],
)
py_test(
name = "multinomial_logistic_test",
size = "large",
srcs = ["multinomial_logistic_test.py"],
local = True,
python_version = "PY3",
srcs_version = "PY3",
deps = [
":datasets",
":multinomial_logistic",
"//tensorflow_privacy/privacy/analysis:compute_dp_sgd_privacy_lib",
],
)
py_library(
name = "datasets",
srcs = ["datasets.py"],
srcs_version = "PY3",
)
py_test(
name = "datasets_test",
size = "small",
srcs = ["datasets_test.py"],
python_version = "PY3",
srcs_version = "PY3",
tags = ["requires-net:external"],
deps = [":datasets"],
)
py_library(
name = "single_layer_softmax",
srcs = ["single_layer_softmax.py"],
srcs_version = "PY3",
deps = [":datasets"],
)
py_test(
name = "single_layer_softmax_test",
size = "medium",
srcs = ["single_layer_softmax_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":datasets",
":single_layer_softmax",
],
)

View file

@ -0,0 +1,53 @@
load("@rules_python//python:defs.bzl", "py_library")
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
py_library(
name = "__init__", # There is already a membership_inference_attack.
srcs = ["__init__.py"],
)
py_library(
name = "keras_evaluation",
srcs = ["keras_evaluation.py"],
deps = ["//tensorflow_privacy/privacy/privacy_tests/membership_inference_attack:keras_evaluation"],
)
py_library(
name = "plotting",
srcs = ["plotting.py"],
srcs_version = "PY3",
deps = [
"//tensorflow_privacy/privacy/privacy_tests/membership_inference_attack:plotting",
],
)
py_library(
name = "membership_inference_attack",
srcs = [
"data_structures.py",
"dataset_slicing.py",
"membership_inference_attack.py",
"models.py",
"plotting.py",
"seq2seq_mia.py",
],
srcs_version = "PY3",
deps = [
"//tensorflow_privacy/privacy/privacy_tests/membership_inference_attack",
],
)
py_library(
name = "privacy_report",
srcs = ["privacy_report.py"],
deps = ["//tensorflow_privacy/privacy/privacy_tests/membership_inference_attack"],
)
py_library(
name = "tf_estimator_evaluation",
srcs = ["tf_estimator_evaluation.py"],
deps = ["//tensorflow_privacy/privacy/privacy_tests/membership_inference_attack:tf_estimator_evaluation"],
)

View file

@ -0,0 +1,90 @@
load("@rules_python//python:defs.bzl", "py_library", "py_test")
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
py_library(
name = "optimizers",
srcs = ["__init__.py"],
)
py_library(
name = "dp_optimizer",
srcs = [
"dp_optimizer.py",
],
srcs_version = "PY3",
deps = ["//tensorflow_privacy/privacy/dp_query:gaussian_query"],
)
py_library(
name = "dp_optimizer_vectorized",
srcs = [
"dp_optimizer_vectorized.py",
],
srcs_version = "PY3",
)
py_library(
name = "dp_optimizer_keras",
srcs = [
"dp_optimizer_keras.py",
],
srcs_version = "PY3",
deps = ["//tensorflow_privacy/privacy/dp_query:gaussian_query"],
)
py_library(
name = "dp_optimizer_keras_vectorized",
srcs = [
"dp_optimizer_keras_vectorized.py",
],
srcs_version = "PY3",
deps = ["//tensorflow_privacy/privacy/dp_query:gaussian_query"],
)
py_test(
name = "dp_optimizer_test",
timeout = "long",
srcs = ["dp_optimizer_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":dp_optimizer",
"//tensorflow_privacy/privacy/dp_query:gaussian_query",
],
)
py_test(
name = "dp_optimizer_vectorized_test",
timeout = "long",
srcs = ["dp_optimizer_vectorized_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [":dp_optimizer_vectorized"],
)
py_test(
name = "dp_optimizer_eager_test",
timeout = "long",
srcs = ["dp_optimizer_eager_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":dp_optimizer",
"//tensorflow_privacy/privacy/dp_query:gaussian_query",
],
)
py_test(
name = "dp_optimizer_keras_test",
timeout = "long",
srcs = ["dp_optimizer_keras_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
"//tensorflow_privacy/privacy/optimizers:dp_optimizer_keras",
"//tensorflow_privacy/privacy/optimizers:dp_optimizer_keras_vectorized",
],
)

View file

@ -0,0 +1,10 @@
load("@rules_python//python:defs.bzl", "py_library")
package(default_visibility = ["//visibility:private"])
licenses(["notice"])
py_library(
name = "privacy_tests",
srcs = ["__init__.py"],
)

View file

@ -0,0 +1,210 @@
load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
py_library(
name = "__init__", # There is already a membership_inference_attack.
srcs = ["__init__.py"],
)
py_library(
name = "plotting",
srcs = ["plotting.py"],
srcs_version = "PY3",
)
py_library(
name = "utils",
srcs = ["utils.py"],
srcs_version = "PY3",
)
py_test(
name = "utils_test",
timeout = "long",
srcs = ["utils_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [":utils"],
)
py_test(
name = "membership_inference_attack_test",
timeout = "long",
srcs = ["membership_inference_attack_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [":membership_inference_attack"],
)
py_test(
name = "data_structures_test",
timeout = "long",
srcs = ["data_structures_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [":membership_inference_attack"],
)
py_test(
name = "dataset_slicing_test",
srcs = ["dataset_slicing_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [":membership_inference_attack"],
)
py_test(
name = "models_test",
timeout = "long",
srcs = ["models_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [":membership_inference_attack"],
)
py_test(
name = "privacy_report_test",
timeout = "long",
srcs = ["privacy_report_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":membership_inference_attack",
":privacy_report",
],
)
py_library(
name = "privacy_report",
srcs = ["privacy_report.py"],
srcs_version = "PY3",
deps = [":membership_inference_attack"],
)
py_library(
name = "membership_inference_attack",
srcs = [
"data_structures.py",
"dataset_slicing.py",
"membership_inference_attack.py",
"models.py",
"plotting.py",
"seq2seq_mia.py",
],
srcs_version = "PY3",
deps = [":utils"],
)
py_library(
name = "utils_tensorboard",
srcs = ["utils_tensorboard.py"],
srcs_version = "PY3",
deps = [":membership_inference_attack"],
)
py_test(
name = "tf_estimator_evaluation_test",
srcs = ["tf_estimator_evaluation_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":membership_inference_attack",
":tf_estimator_evaluation",
],
)
py_library(
name = "tf_estimator_evaluation",
srcs = ["tf_estimator_evaluation.py"],
srcs_version = "PY3",
deps = [
":membership_inference_attack",
":utils",
":utils_tensorboard",
],
)
py_binary(
name = "tf_estimator_evaluation_example",
srcs = ["tf_estimator_evaluation_example.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":membership_inference_attack",
":tf_estimator_evaluation",
],
)
py_library(
name = "keras_evaluation",
srcs = ["keras_evaluation.py"],
srcs_version = "PY3",
deps = [
":membership_inference_attack",
":utils",
":utils_tensorboard",
],
)
py_test(
name = "seq2seq_mia_test",
srcs = ["seq2seq_mia_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [":membership_inference_attack"],
)
py_binary(
name = "keras_evaluation_example",
srcs = ["keras_evaluation_example.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":keras_evaluation",
":membership_inference_attack",
],
)
py_test(
name = "keras_evaluation_test",
srcs = ["keras_evaluation_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":keras_evaluation",
":membership_inference_attack",
],
)
py_library(
name = "advanced_mia",
srcs = [
"advanced_mia.py",
],
srcs_version = "PY3",
deps = [":utils"],
)
py_test(
name = "advanced_mia_test",
timeout = "long",
srcs = ["advanced_mia_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [":advanced_mia"],
)
py_binary(
name = "advanced_mia_example",
srcs = ["advanced_mia_example.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":advanced_mia",
":membership_inference_attack",
":utils",
],
)

View file

@ -0,0 +1,16 @@
load("@rules_python//python:defs.bzl", "py_binary")
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
py_binary(
name = "example",
srcs = ["example.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
"//tensorflow_privacy/privacy/privacy_tests/membership_inference_attack",
"//tensorflow_privacy/privacy/privacy_tests/membership_inference_attack:privacy_report",
],
)

View file

@ -0,0 +1,3 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])

View file

@ -0,0 +1,36 @@
load("@rules_python//python:defs.bzl", "py_library", "py_test")
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
py_library(
name = "secret_sharer",
srcs = ["__init__.py"],
)
py_library(
name = "exposures",
srcs = ["exposures.py"],
srcs_version = "PY3",
)
py_test(
name = "exposures_test",
srcs = ["exposures_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [":exposures"],
)
py_library(
name = "generate_secrets",
srcs = ["generate_secrets.py"],
srcs_version = "PY3",
)
py_test(
name = "generate_secrets_test",
srcs = ["generate_secrets_test.py"],
deps = [":generate_secrets"],
)

View file

@ -0,0 +1,22 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@rules_python//python:defs.bzl", "py_library")
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
py_library(
name = "tensorflow_privacy_v1",
srcs = ["__init__.py"],
srcs_version = "PY3",
deps = [
"//tensorflow_privacy/privacy/estimators/v1:dnn",
"//tensorflow_privacy/privacy/optimizers:dp_optimizer",
"//tensorflow_privacy/privacy/optimizers:dp_optimizer_vectorized",
],
)
build_test(
name = "tensorflow_privacy_build_test",
targets = [":tensorflow_privacy_v1"],
)

114
tutorials/BUILD Normal file
View file

@ -0,0 +1,114 @@
load("@rules_python//python:defs.bzl", "py_binary", "py_library")
licenses(["notice"])
py_library(
name = "mnist_dpsgd_tutorial_common",
srcs = ["mnist_dpsgd_tutorial_common.py"],
srcs_version = "PY3",
)
py_binary(
name = "mnist_dpsgd_tutorial",
srcs = ["mnist_dpsgd_tutorial.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":mnist_dpsgd_tutorial_common",
"//tensorflow_privacy/privacy/analysis:compute_dp_sgd_privacy_lib",
"//tensorflow_privacy/privacy/optimizers:dp_optimizer",
],
)
py_binary(
name = "mnist_dpsgd_tutorial_eager",
srcs = ["mnist_dpsgd_tutorial_eager.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
"//tensorflow_privacy/privacy/analysis:rdp_accountant",
"//tensorflow_privacy/privacy/optimizers:dp_optimizer",
],
)
py_binary(
name = "mnist_dpsgd_tutorial_keras",
srcs = ["mnist_dpsgd_tutorial_keras.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
"//tensorflow_privacy/privacy/analysis:rdp_accountant",
"//tensorflow_privacy/privacy/optimizers:dp_optimizer_keras",
],
)
py_binary(
name = "mnist_dpsgd_tutorial_keras_model",
srcs = ["mnist_dpsgd_tutorial_keras_model.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
"//tensorflow_privacy/privacy/analysis:rdp_accountant",
"//tensorflow_privacy/privacy/keras_models:dp_keras_model",
],
)
py_binary(
name = "mnist_dpsgd_tutorial_vectorized",
srcs = ["mnist_dpsgd_tutorial_vectorized.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
"//tensorflow_privacy/privacy/analysis:rdp_accountant",
"//tensorflow_privacy/privacy/optimizers:dp_optimizer_vectorized",
],
)
py_binary(
name = "mnist_dpsgd_tutorial_tpu",
srcs = ["mnist_dpsgd_tutorial_tpu.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":mnist_dpsgd_tutorial_common",
"//tensorflow_privacy/privacy/analysis:compute_dp_sgd_privacy_lib",
"//tensorflow_privacy/privacy/optimizers:dp_optimizer",
],
)
py_binary(
name = "mnist_lr_tutorial",
srcs = ["mnist_lr_tutorial.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
"//tensorflow_privacy/privacy/analysis:rdp_accountant",
"//tensorflow_privacy/privacy/optimizers:dp_optimizer",
],
)
py_binary(
name = "lm_dpsgd_tutorial",
srcs = ["lm_dpsgd_tutorial.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
"//tensorflow_privacy/privacy/analysis:rdp_accountant",
"//tensorflow_privacy/privacy/optimizers:dp_optimizer",
],
)
py_binary(
name = "movielens_tutorial",
srcs = ["movielens_tutorial.py"],
deps = [
"//tensorflow_privacy/privacy/analysis:gdp_accountant",
"//tensorflow_privacy/privacy/optimizers:dp_optimizer",
],
)
filegroup(
name = "ignore_srcs",
srcs = ["bolton_tutorial.py"],
tags = ["ignore_srcs"],
)

View file

@ -0,0 +1,10 @@
load("@rules_python//python:defs.bzl", "py_binary")
licenses(["notice"])
py_binary(
name = "mnist_scratch",
srcs = ["mnist_scratch.py"],
python_version = "PY3",
srcs_version = "PY3",
)