-
Notifications
You must be signed in to change notification settings - Fork 452
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
PiperOrigin-RevId: 447573314
- Loading branch information
1 parent
137f795
commit 97eec1a
Showing
11 changed files
with
581 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,9 @@ | |
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# pylint: skip-file | ||
# pyformat: disable | ||
|
||
import os | ||
import scipy.stats | ||
|
||
|
@@ -113,7 +116,7 @@ def generate_ours_offline(keep, scores, check_keep, check_scores, in_size=100000 | |
dat_out.append(scores[~keep[:, j], j, :]) | ||
|
||
out_size = min(min(map(len,dat_out)), out_size) | ||
|
||
dat_out = np.array([x[:out_size] for x in dat_out]) | ||
|
||
mean_out = np.median(dat_out, 1) | ||
|
@@ -160,7 +163,7 @@ def do_plot(fn, keep, scores, ntest, legend='', metric='auc', sweep_fn=sweep, ** | |
fpr, tpr, auc, acc = sweep_fn(np.array(prediction), np.array(answers, dtype=bool)) | ||
|
||
low = tpr[np.where(fpr<.001)[0][-1]] | ||
|
||
print('Attack %s AUC %.4f, Accuracy %.4f, [email protected]%%FPR of %.4f'%(legend, auc,acc, low)) | ||
|
||
metric_text = '' | ||
|
@@ -206,7 +209,7 @@ def fig_fpr_tpr(): | |
"Global threshold\n", | ||
metric='auc' | ||
) | ||
|
||
plt.semilogx() | ||
plt.semilogy() | ||
plt.xlim(1e-5,1) | ||
|
@@ -220,5 +223,6 @@ def fig_fpr_tpr(): | |
plt.show() | ||
|
||
|
||
load_data("exp/cifar10/") | ||
fig_fpr_tpr() | ||
if __name__ == '__main__': | ||
load_data("exp/cifar10/") | ||
fig_fpr_tpr() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.