forked from TrentBrick/PyTorchDiscreteFlows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexperiments.py
187 lines (168 loc) · 14.1 KB
/
experiments.py
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
import random
from train_utils import *
seed = 42
random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
torch.cuda.manual_seed_all(seed) # if you are using multi-GPU.
np.random.seed(seed) # Numpy module.
random.seed(seed) # Python random module.
torch.manual_seed(seed)
torch.backends.cudnn.benchmark = False
torch.backends.cudnn.deterministic = True
os.environ['PYTHONHASHSEED'] = str(seed)
DEBUG = False
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--exp', type=int)
parse = parser.parse_args()
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
#device = torch.device('cpu')
#exp1
if parse.exp == 1:
train_toy_dataset('bipartite')
train_toy_dataset('autoreg')
elif parse.exp == 2:
#exp2
Train_synth_data(k=5, d=5, n_samples=10000, disc_layer_type='bipartite', epoch=100, batch_size=1024, hidden_layer=0, path='exp2', save=True, test_per_epoch=True, af='linear', alpha=1, beta=16, id_init=False, k_fold=5, manual_prob=False)
Train_synth_data(k=5, d=5, n_samples=10000, disc_layer_type='autoreg', epoch=100, batch_size=1024, hidden_layer=64, path='exp2', save=True, test_per_epoch=True, af='linear', alpha=1, beta=1, id_init=False, k_fold=5, manual_prob=False)
elif parse.exp == 3:
#exp3
Train_synth_data(k=5, d=10, n_samples=10000, disc_layer_type='bipartite', epoch=100, batch_size=1024, hidden_layer=0, path='exp3', save=True, test_per_epoch=True, af='linear', alpha=1, beta=16, id_init=False, k_fold=5, manual_prob=False)
Train_synth_data(k=5, d=10, n_samples=10000, disc_layer_type='autoreg', epoch=100, batch_size=1024, hidden_layer=64, path='exp3', save=True, test_per_epoch=True, af='linear', alpha=1, beta=1, id_init=False, k_fold=5, manual_prob=False)
elif parse.exp == 4:
#exp4
Train_synth_data(k=10, d=5, n_samples=10000, disc_layer_type='bipartite', epoch=100, batch_size=1024, hidden_layer=0, path='exp4', save=True, test_per_epoch=True, af='linear', alpha=1, beta=16, id_init=False, k_fold=5, manual_prob=False)
Train_synth_data(k=10, d=5, n_samples=10000, disc_layer_type='autoreg', epoch=100, batch_size=1024, hidden_layer=64, path='exp4', save=True, test_per_epoch=True, af='linear', alpha=1, beta=1, id_init=False, k_fold=5, manual_prob=False)
elif parse.exp == 5:
#exp6
Train_copula(device, copula_data_path='../data/coup_data_4_2_weak_corr.npy', disc_layer_type='bipartite', epoch=100, path='exp5', alpha=1, beta=8, id_init=False)
Train_copula(device, copula_data_path='../data/coup_data_4_2_weak_corr.npy', disc_layer_type='autoreg', epoch=100, hidden_layer=64, path='exp5', alpha=1, beta=16, id_init=False)
elif parse.exp == 6:
#exp7
Train_copula(device, copula_data_path='../data/coup_data_4_2_moderate_corr.npy', disc_layer_type='bipartite', epoch=100, path='exp6', alpha=1, beta=8, id_init=False)
Train_copula(device, copula_data_path='../data/coup_data_4_2_moderate_corr.npy', disc_layer_type='autoreg', epoch=100, hidden_layer=64, path='exp6', alpha=1, beta=16, id_init=False)
elif parse.exp == 7:
#exp8
Train_copula(device, copula_data_path='../data/coup_data_4_2_strong_corr.npy', disc_layer_type='bipartite', epoch=100, path='exp7', alpha=1, beta=8, id_init=False)
Train_copula(device, copula_data_path='../data/coup_data_4_2_strong_corr.npy', disc_layer_type='autoreg', epoch=100, hidden_layer=64, path='exp7', alpha=1, beta=16, id_init=False)
elif parse.exp == 8:
#exp9
Train_copula(device, copula_data_path='../data/coup_data_4_2.npy', disc_layer_type='bipartite', epoch=100, path='exp8', alpha=1, beta=8, id_init=False)
Train_copula(device, copula_data_path='../data/coup_data_4_2.npy', disc_layer_type='autoreg', epoch=100, hidden_layer=64, path='exp8', alpha=1, beta=16, id_init=False)
elif parse.exp == 9:
mushroom_data_path = '../data/agaricus-lepiota.data'
#Train_mushroom(device, mushroom_data_path=mushroom_data_path, disc_layer_type='bipartite', epoch=100, path='id_exp10_a1b8', alpha=1, beta=8, id_init=True)
Train_mushroom(device, mushroom_data_path=mushroom_data_path, disc_layer_type='bipartite', epoch=100, path='exp9_a1b8', alpha=1, beta=8, id_init=False)
Train_mushroom(device, mushroom_data_path=mushroom_data_path, hidden_layer=128, disc_layer_type='autoreg', epoch=100, path='exp10', alpha=1, beta=1, id_init=False)
#Train_mushroom(device, mushroom_data_path=mushroom_data_path, disc_layer_type='bipartite', epoch=100, path='id_exp10_a1b4', alpha=1, beta=4, id_init=True)
Train_mushroom(device, mushroom_data_path=mushroom_data_path, disc_layer_type='bipartite', epoch=100, path='exp9_a1b4', alpha=1, beta=4, id_init=False)
#Train_mushroom(device, mushroom_data_path=mushroom_data_path, disc_layer_type='bipartite', epoch=100, path='id_exp10_a1b2', alpha=1, beta=2, id_init=True)
Train_mushroom(device, mushroom_data_path=mushroom_data_path, disc_layer_type='bipartite', epoch=100, path='exp9_a1b2', alpha=1, beta=2, id_init=False)
#Train_mushroom(device, mushroom_data_path=mushroom_data_path, disc_layer_type='bipartite', epoch=100, path='id_exp10_a2b8', alpha=2, beta=8, id_init=True)
Train_mushroom(device, mushroom_data_path=mushroom_data_path, disc_layer_type='bipartite', epoch=100, path='exp9_a2b8', alpha=2, beta=8, id_init=False)
#Train_mushroom(device, mushroom_data_path=mushroom_data_path, disc_layer_type='bipartite', epoch=100, path='id_exp10_a4b8', alpha=4, beta=8, id_init=True)
Train_mushroom(device, mushroom_data_path=mushroom_data_path, disc_layer_type='bipartite', epoch=100, path='exp9_a4b8', alpha=4, beta=8, id_init=False)
######## MNIST ##########
elif parse.exp == 10:
for i in range(3):
print('kfold' + str(i))
# beta=1
Train_MNIST(digit='all', disc_layer_type='autoreg', batch_size=500, epoch=200, hidden_layer=784 * 2,
temp_decay=1, lr_decay=1, path='auto_h8', save=True, image_process=False, CNN=False,
test_per_epoch=True, dim=(14, 14), sample_size=15, af='linear', alpha=1, beta=1, id_init=False,
kfold=i)
# beta=1/4
Train_MNIST(digit='all', disc_layer_type='bipartite', batch_size=500, epoch=200, hidden_layer=784, temp_decay=1,
lr_decay=1, path='IDa1b1_4', save=True, image_process=False, CNN=False, test_per_epoch=True,
dim=(14, 14), sample_size=15, af='linear', alpha=1, beta=1 / 4, id_init=True, kfold=i)
# beta=1/16
Train_MNIST(digit='all', disc_layer_type='bipartite', batch_size=500, epoch=200, hidden_layer=784, temp_decay=1,
lr_decay=1, path='IDa1b1_16', save=True, image_process=False, CNN=False, test_per_epoch=True,
dim=(14, 14), sample_size=15, af='linear', alpha=1, beta=1 / 16, id_init=True, kfold=i)
# alpha=2
Train_MNIST(digit='all', disc_layer_type='bipartite', batch_size=500, epoch=200, hidden_layer=784, temp_decay=1,
lr_decay=1, path='IDa2b1', save=True, image_process=False, CNN=False, test_per_epoch=True,
dim=(14, 14), sample_size=15, af='linear', alpha=2, beta=1, id_init=True, kfold=i)
# alpha=4
Train_MNIST(digit='all', disc_layer_type='bipartite', batch_size=500, epoch=200, hidden_layer=784, temp_decay=1,
lr_decay=1, path='IDa4b1', save=True, image_process=False, CNN=False, test_per_epoch=True,
dim=(14, 14), sample_size=15, af='linear', alpha=4, beta=1, id_init=True, kfold=i)
# alpha=8
Train_MNIST(digit='all', disc_layer_type='bipartite', batch_size=500, epoch=200, hidden_layer=784, temp_decay=1,
lr_decay=1, path='IDa8b1', save=True, image_process=False, CNN=False, test_per_epoch=True,
dim=(14, 14), sample_size=15, af='linear', alpha=8, beta=1, id_init=True, kfold=i)
# beta=1
Train_MNIST(digit='all', disc_layer_type='bipartite', batch_size=500, epoch=200, hidden_layer=784, temp_decay=1,
lr_decay=1, path='a1b1', save=True, image_process=False, CNN=False, test_per_epoch=True,
dim=(14, 14), sample_size=15, af='linear', alpha=1, beta=1, id_init=False, kfold=i)
# beta=1/4
Train_MNIST(digit='all', disc_layer_type='bipartite', batch_size=500, epoch=200, hidden_layer=784, temp_decay=1,
lr_decay=1, path='a1b1_4', save=True, image_process=False, CNN=False, test_per_epoch=True,
dim=(14, 14), sample_size=15, af='linear', alpha=1, beta=1 / 4, id_init=False, kfold=i)
# beta=1/16
Train_MNIST(digit='all', disc_layer_type='bipartite', batch_size=500, epoch=200, hidden_layer=784, temp_decay=1,
lr_decay=1, path='a1b1_16', save=True, image_process=False, CNN=False, test_per_epoch=True,
dim=(14, 14), sample_size=15, af='linear', alpha=1, beta=1 / 16, id_init=False, kfold=i)
# alpha=2
Train_MNIST(digit='all', disc_layer_type='bipartite', batch_size=500, epoch=200, hidden_layer=784, temp_decay=1,
lr_decay=1, path='a2b1', save=True, image_process=False, CNN=False, test_per_epoch=True,
dim=(14, 14), sample_size=15, af='linear', alpha=2, beta=1, id_init=False, kfold=i)
# alpha=4
Train_MNIST(digit='all', disc_layer_type='bipartite', batch_size=500, epoch=200, hidden_layer=784, temp_decay=1,
lr_decay=1, path='a4b1', save=True, image_process=False, CNN=False, test_per_epoch=True,
dim=(14, 14), sample_size=15, af='linear', alpha=4, beta=1, id_init=False, kfold=i)
# alpha=8
Train_MNIST(digit='all', disc_layer_type='bipartite', batch_size=500, epoch=200, hidden_layer=784, temp_decay=1,
lr_decay=1, path='a8b1', save=True, image_process=False, CNN=False, test_per_epoch=True,
dim=(14, 14), sample_size=15, af='linear', alpha=8, beta=1, id_init=False, kfold=i)
######## Genetic Test ##########
elif parse.exp == 11:
for i in range(3):
print('kfold' + str(i))
# beta=1
Train_805(disc_layer_type='bipartite', batch_size=500, epoch=200, hidden_layer=805*2, path='IDa1b1', save=True, test_per_epoch=True, sample_size=15, af='linear', alpha=1, beta=1, id_init=True, kfold=i)
# beta=1/4
Train_805(disc_layer_type='bipartite', batch_size=500, epoch=200, hidden_layer=805*2, path='IDa1b1_4', save=True, test_per_epoch=True, sample_size=15, af='linear', alpha=1, beta=1/4, id_init=True, kfold=i)
# beta=1/16
Train_805(disc_layer_type='bipartite', batch_size=500, epoch=200, hidden_layer=805*2, path='IDa1b1_16', save=True, test_per_epoch=True, sample_size=15, af='linear', alpha=1, beta=1/16, id_init=True, kfold=i)
# alpha=2
Train_805(disc_layer_type='bipartite', batch_size=500, epoch=200, hidden_layer=805*2, path='IDa2b1', save=True, test_per_epoch=True, sample_size=15, af='linear', alpha=2, beta=1, id_init=True, kfold=i)
# alpha=4
Train_805(disc_layer_type='bipartite', batch_size=500, epoch=200, hidden_layer=805*2, path='IDa4b1', save=True, test_per_epoch=True, sample_size=15, af='linear', alpha=4, beta=1, id_init=True, kfold=i)
# alpha=8
Train_805(disc_layer_type='bipartite', batch_size=500, epoch=200, hidden_layer=805*2, path='IDa8b1', save=True, test_per_epoch=True, sample_size=15, af='linear', alpha=8, beta=1, id_init=True, kfold=i)
# beta=1
Train_805(disc_layer_type='bipartite', batch_size=500, epoch=200, hidden_layer=805*2, path='a1b1', save=True, test_per_epoch=True, sample_size=15, af='linear', alpha=1, beta=1, id_init=False, kfold=i)
# beta=1/4
Train_805(disc_layer_type='bipartite', batch_size=500, epoch=200, hidden_layer=805*2, path='a1b1_4', save=True, test_per_epoch=True, sample_size=15, af='linear', alpha=1, beta=1/4, id_init=False, kfold=i)
# beta=1/16
Train_805(disc_layer_type='bipartite', batch_size=500, epoch=200, hidden_layer=805*2, path='a1b1_16', save=True, test_per_epoch=True, sample_size=15, af='linear', alpha=1, beta=1/16, id_init=False, kfold=i)
# alpha=2
Train_805(disc_layer_type='bipartite', batch_size=500, epoch=200, hidden_layer=805*2, path='a2b1', save=True, test_per_epoch=True, sample_size=15, af='linear', alpha=2, beta=1, id_init=False, kfold=i)
# alpha=4
Train_805(disc_layer_type='bipartite', batch_size=500, epoch=200, hidden_layer=805*2, path='a4b1', save=True, test_per_epoch=True, sample_size=15, af='linear', alpha=4, beta=1, id_init=False, kfold=i)
# alpha=8
Train_805(disc_layer_type='bipartite', batch_size=500, epoch=200, hidden_layer=805*2, path='a8b1', save=True, test_per_epoch=True, sample_size=15, af='linear', alpha=8, beta=1, id_init=False, kfold=i)
# City Scapes
elif parse.exp == 12:
Train_cityscapes(disc_layer_type='autoreg', batch_size=150, epoch=200, hidden_layer=512*2, path='autoreg',
save=True, test_per_epoch=True, af='linear', alpha=1, beta=1, id_init=False)
# beta=1
Train_cityscapes(disc_layer_type='bipartite', batch_size=150, epoch=200, hidden_layer=805 * 2, path='a1b1',
save=True, test_per_epoch=True, af='linear', alpha=1, beta=1, id_init=False)
# beta=1/4
Train_cityscapes(disc_layer_type='bipartite', batch_size=150, epoch=200, hidden_layer=805 * 2, path='a1b1_4',
save=True, test_per_epoch=True, af='linear', alpha=1, beta=1 / 4, id_init=False)
# beta=1/16
Train_cityscapes(disc_layer_type='bipartite', batch_size=150, epoch=200, hidden_layer=805 * 2, path='a1b1_16',
save=True, test_per_epoch=True, af='linear', alpha=1, beta=1 / 16, id_init=False)
# alpha=2
Train_cityscapes(disc_layer_type='bipartite', batch_size=150, epoch=200, hidden_layer=805 * 2, path='a2b1',
save=True, test_per_epoch=True, af='linear', alpha=2, beta=1, id_init=False)
# alpha=4
Train_cityscapes(disc_layer_type='bipartite', batch_size=150, epoch=200, hidden_layer=805 * 2, path='a4b1',
save=True, test_per_epoch=True, af='linear', alpha=4, beta=1, id_init=False)
# alpha=8
Train_cityscapes(disc_layer_type='bipartite', batch_size=150, epoch=200, hidden_layer=805 * 2, path='a8b1',
save=True, test_per_epoch=True, af='linear', alpha=8, beta=1, id_init=False)