forked from 626_privacy/tensorflow_privacy
Updates to the codelab.
PiperOrigin-RevId: 318051333
This commit is contained in:
parent
c01e7b71ab
commit
74bd89d754
1 changed files with 20 additions and 10 deletions
|
@ -94,12 +94,6 @@
|
|||
"outputs": [],
|
||||
"source": [
|
||||
"#@title Import statements.\n",
|
||||
"try:\n",
|
||||
" # %tensorflow_version only exists in Colab.\n",
|
||||
" %tensorflow_version 1.x\n",
|
||||
"except Exception:\n",
|
||||
" pass\n",
|
||||
"\n",
|
||||
"import numpy as np\n",
|
||||
"from typing import Tuple, Text\n",
|
||||
"from scipy import special\n",
|
||||
|
@ -107,7 +101,12 @@
|
|||
"import tensorflow as tf\n",
|
||||
"import tensorflow_datasets as tfds\n",
|
||||
"\n",
|
||||
"tf.compat.v1.logging.set_verbosity(tf.logging.ERROR)"
|
||||
"# Set verbosity.\n",
|
||||
"tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)\n",
|
||||
"from warnings import simplefilter\n",
|
||||
"from sklearn.exceptions import ConvergenceWarning\n",
|
||||
"simplefilter(action=\"ignore\", category=ConvergenceWarning)\n",
|
||||
"simplefilter(action=\"ignore\", category=FutureWarning)"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -274,12 +273,23 @@
|
|||
"#@markdown doesn't have privacy issues according to this test. Higher values,\n",
|
||||
"#@markdown on the contrary, indicate potential privacy issues.\n",
|
||||
"\n",
|
||||
"#@markdown Note: This will take a while, since it also trains ML models to\n",
|
||||
"#@markdown separate train/test examples.\n",
|
||||
"\n",
|
||||
"labels_train = np.argmax(y_train, axis=1)\n",
|
||||
"labels_test = np.argmax(y_test, axis=1)\n",
|
||||
"\n",
|
||||
"results_without_classifiers = mia.run_all_attacks(\n",
|
||||
" loss_train,\n",
|
||||
" loss_test,\n",
|
||||
" logits_train,\n",
|
||||
" logits_test,\n",
|
||||
" labels_train,\n",
|
||||
" labels_test,\n",
|
||||
" attack_classifiers=[],\n",
|
||||
")\n",
|
||||
"print(results_without_classifiers)\n",
|
||||
"\n",
|
||||
"# Note: This will take a while, since it also trains ML models to\n",
|
||||
"# separate train/test examples. If it's taking too looking, use\n",
|
||||
"# the `run_all_attacks` function instead.\n",
|
||||
"attack_result_summary = mia.run_all_attacks_and_create_summary(\n",
|
||||
" loss_train,\n",
|
||||
" loss_test,\n",
|
||||
|
|
Loading…
Reference in a new issue