-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathpate_runanalysis.py
More file actions
83 lines (60 loc) · 2.89 KB
/
pate_runanalysis.py
File metadata and controls
83 lines (60 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
from syft.frameworks.torch.dp import pate as pate_analysis
import numpy as np
import sys
import all_config as config
config = config.config
# Only to be run on my system! Problem with running on server
data_type = "Arxiv" # Arxiv, Reddit, Amazon
epsilon = 1
if data_type == "Reddit":
delta = 10e-5 # 0.00008
elif data_type == "Arxiv":
delta = 10e-5 # 0.00001
elif data_type == "Amazon":
delta = 10e-4 # 0.0004
withMLP = True
if withMLP:
pate_type = "PATEwithMLP"
else:
pate_type = "PATEwithoutMLP"
# load array
# 500 queries
non_noisy_preds = np.load(
"stdoutnew1" + pate_type + str(epsilon) + "500.txt" + data_type + str(epsilon) + "teacherpred.npy")
stdnt_labels = np.load("stdoutnew1" + pate_type + str(epsilon) + "500.txt" + data_type + str(epsilon) + "stdntlabels.npy")
# 1K queries
# non_noisy_preds = np.load(
# "stdoutnew1" + pate_type + str(epsilon) + ".txt" + data_type + str(epsilon) + "teacherpred.npy")
# stdnt_labels = np.load("stdoutnew1" + pate_type + str(epsilon) + ".txt" + data_type + str(epsilon) + "stdntlabels.npy")
print("non_noisy_preds", non_noisy_preds)
print("stdnt_labels", stdnt_labels)
data_dep_eps, data_ind_eps = pate_analysis.perform_analysis(teacher_preds=non_noisy_preds, indices=stdnt_labels,
noise_eps=epsilon, delta=delta, moments=8)
print("Data Independent Epsilon:", data_ind_eps)
print("Data Dependent Epsilon:", data_dep_eps)
sys.exit()
# withMLP = True
for withMLP in [True, False]:
for epsilon in [0.1, 0.2, 0.4, 0.8, 1]:
# epsilon = 0.1
for data_type in ["Reddit", "Amazon"]:#, "Arxiv"]:
# data_type = "Cora" # Reddit, Amazon, Arxiv
if withMLP:
pate_type = "PATEwithMLP"
else:
pate_type = "PATEwithoutMLP"
if data_type == "Reddit":
delta = 0.00008
elif data_type == "Arxiv":
delta = 0.00001
elif data_type == "Amazon":
delta = 0.0004
print("stdoutnew1"+pate_type+str(epsilon)+".txt"+data_type+str(epsilon)+"teacherpred.npy")
# print("stdoutnew1"+pate_type+str(epsilon)+".txt"+data_type+str(epsilon)+"stdntlabels.npy")
# load array
non_noisy_preds = np.load("stdoutnew1"+pate_type+str(epsilon)+".txt"+data_type+str(epsilon)+"teacherpred.npy")
stdnt_labels = np.load("stdoutnew1"+pate_type+str(epsilon)+".txt"+data_type+str(epsilon)+"stdntlabels.npy")
data_dep_eps, data_ind_eps = pate_analysis.perform_analysis(teacher_preds=non_noisy_preds, indices=stdnt_labels,
noise_eps=epsilon, delta=delta)
print("Data Independent Epsilon:", data_ind_eps)
print("Data Dependent Epsilon:", data_dep_eps)