forked from soundsinteresting/perpca
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathppca.py
580 lines (485 loc) · 21.7 KB
/
ppca.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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
import numpy as np
from numpy import linalg as LA
import scipy.stats as st
import statsmodels.api as sm
import os
import matplotlib.pyplot as plt
import copy
from algs import *
class Experiment():
def toytest(inputargs):
args = {
'method':'power',
'd':15,
'num_client':100,
'nlc':10,
'ngc':2,
'num_dp_per_client':1000,
'global_epochs':30,
'local_epochs':10,
'n_power':1,
'eta':0.1,
'rho':1,
'decay':1-0.05,
}
np.random.seed(2022)
lcs = gen_local_components(ttd=args['d'], ini_id=2, ter_id=11, num_per_client=args['nlc'], num_client=args['num_client'])
gcs = np.array([[1/np.sqrt(2.), 1/np.sqrt(2.), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1/np.sqrt(3.), 1/np.sqrt(3.), 1/np.sqrt(3.)]])
gcs/=10
print(lcs[0])
Y=generate_data(g_cs=gcs,l_cs=lcs,d=args['d'],num_dp=args['num_dp_per_client'])
U_glb = initial_u(Y, d=args['d'], ngc=args['nlc']+args['ngc'])
print('statistical optimal training loss')
print(loss(Y, gcs.T, [lc.T for lc in lcs]))
Y_test = generate_data(g_cs=gcs, l_cs=lcs, d=args['d'], num_dp=args['num_dp_per_client'])
print('statistical optimal test loss')
print(loss(Y_test, gcs.T, [lc.T for lc in lcs]))
print('global model test loss:')
print(loss(Y_test, U_glb))
U, V, lv = personalized_pca_dgd(Y, args=args)
print('personalized model test loss:')
print(loss(Y_test, U, V))
U, V, lv = two_shot_pca(Y, args=args)
print('two shot train loss:')
print(loss(Y, U, V))
print('two shot test loss:')
print(loss(Y_test, U, V))
def borrowpowertest(inputargs):
args = {
'd':15,
'num_client':100,
'nlc':1,
'ngc':1,
'seed': 2021,
'local_ratio':0.99,
'num_dp_per_client':10000,
'test_num_dp_per_client':100,
'global_epochs':100,
'local_epochs':10,
'choice1':1,
#'adaptivestepsize':1,
#'logprogress':1,
'n_power':1,
'eta':1e-1,#0.01,
'rho':1,
'decay':1-0.05,
#'aggregationinit':1,
#'randominit':1,
}
for key in inputargs:
args[key] = inputargs[key]
print(args)
#num_client=20
#np.random.seed(2021)
np.random.seed(args['seed'])
lcs = gen_local_components(ttd=args['d'], ini_id=args['ngc'], ter_id=args['d']-1, num_per_client=args['nlc'], num_client=args['num_client'])
gcs = np.zeros((args['ngc'],args['d']))
for i in range(args['ngc']):
gcs[i,i] = 1
Y1=generate_data(g_cs=gcs,l_cs=lcs[:int(len(lcs)*0.5)],d=args['d'],local_ratio=args['local_ratio'], num_dp=args['num_dp_per_client']//10)
Y2=generate_data(g_cs=gcs,l_cs=lcs[int(len(lcs)*0.5):],d=args['d'],local_ratio=args['local_ratio'], num_dp=args['num_dp_per_client'])
Y = Y1+Y2
lpcs = [single_PCA(Yi, args['nlc']+args['ngc']) for Yi in Y]
singletrainingloss = np.array([single_loss(Y[i], lpcs[i]) for i in range(len(Y))])
U_glb = initial_u(Y, d=args['d'], ngc=args['nlc']+args['ngc'])
print("---------------------------------------")
print('statistical optimal training loss %.4f'% loss(Y, gcs.T, [lc.T for lc in lcs]))
Y_test = generate_data(g_cs=gcs, l_cs=lcs, d=args['d'], num_dp=args['test_num_dp_per_client'])
print('statistical optimal test loss: %.4f'% loss(Y_test, gcs.T, [lc.T for lc in lcs]))
grouploss = lambda gs,ls : np.array([single_loss(Y_test[i], gs[i], ls[i], nov=0) for i in range(len(Y_test))])
singletestloss = grouploss([gcs.T for ii in range(args['num_client'])], [lc.T for lc in lcs])
print('statistical optimal individual test loss: %.4f, %.4f'%(np.mean(singletestloss[:len(singletestloss)//2]), np.mean(singletestloss[len(singletestloss)//2:])))
print("---------------------------------------")
print('global model test loss: %.4f'%loss(Y_test, U_glb))
singletestloss = np.array([single_loss(Y_test[i], U_glb) for i in range(len(Y_test))])
print('global model indiv model test loss: %.4f, %.4f'%(np.mean(singletestloss[:len(singletestloss)//2]), np.mean(singletestloss[len(singletestloss)//2:])))
print("---------------------------------------")
print('indiv model training loss: %.4f, %.4f' %(np.mean(singletrainingloss[:len(singletrainingloss)//2]), np.mean(singletrainingloss[len(singletrainingloss)//2:])))
singletestloss = np.array([single_loss(Y_test[i], lpcs[i]) for i in range(len(Y_test))])
print('indiv model test loss: %.4f, %.4f'%(np.mean(singletestloss[:len(singletestloss)//2]), np.mean(singletestloss[len(singletestloss)//2:])))
print("---------------------------------------")
U, V, lv = personalized_pca_dgd(Y, args=args)
print('personalized model test loss: %.4f'%loss(Y_test, U, V))
singletestloss = grouploss(U, V)
print('personalized indiv model test loss: %.4f, %.4f'%(np.mean(singletestloss[:len(singletestloss)//2]), np.mean(singletestloss[len(singletestloss)//2:])))
print('personalized subspace loss: %.4f, %.4f'%(subspace_error_avg(U,gcs.T), subspace_error_avg(V,[lc.T for lc in lcs])))
U, V, lv = two_shot_pca(Y, args=args)
print("---------------------------------------")
print('two shot test loss: %.4f'% loss(Y_test, U, V))
singletestloss = grouploss(U, V)
print('two shot indiv model test loss: %.4f, %.4f'%(np.mean(singletestloss[:len(singletestloss)//2]), np.mean(singletestloss[len(singletestloss)//2:])))
print('two shot subspace loss: %.4f, %.4f'%(subspace_error_avg(U,gcs.T), subspace_error_avg(V,[lc.T for lc in lcs])))
#print(subspace_error_avg(U,gcs.T), subspace_error_avg(V,[lc.T for lc in lcs]))
def img_test(inputargs):
args = {
'method': 'power',
'd': 100,
'num_client': 4,
'nlc': 100,
'ngc': 10,
'num_dp_per_client': 100,
'global_epochs': 120,
'local_epochs': 1,
'n_power': 1,
'eta': 1e-1,
#'choice1':1,
#'adaptivestepsize':1,
'rho': 1e1,
'lambda': 0,
'decay': 1 - 0.1,
'logprogress':1,
'precise':1,
'inverse':1,
}
for key in inputargs:
if key not in {'nlc','ngc'}:
args[key] = inputargs[key]
np.random.seed(args['seed'])
print(args)
from imgpro import gen_img_data
Y = gen_img_data(args)
print('number of images %d'%len(Y))
args['num_client'] = len(Y)
args['d'] = len(Y[0][0])
args['num_dp_per_client'] = len(Y[0])
U_glb = initial_u(Y, d=args['d'], ngc=args['nlc'] + args['ngc'])
print(U_glb.shape)
reconstruct0 = (U_glb @ U_glb.T @ (Y[0].T)).T
Y_test = copy.deepcopy(Y) # generate_data(g_cs=gcs, l_cs=lcs, d=args['d'], num_dp=args['num_dp_per_client'])
print('global model test loss:')
print(loss(Y_test, U_glb))
if args['algorithm'] in {'rpca'}:
print('solving robust pca via admm')
U, V = robust_pca_admm(Y,args)
for figidx in range(len(Y)):
print('saving image {}'.format(figidx))
reconstruct0 = U[figidx]#.T
plt.imshow(reconstruct0,cmap='gray')
plt.axis('off')
plt.savefig('processedframes/'+'rpca_bg_'+str(figidx)+'.png', bbox_inches='tight')
reconstruct1 = V[figidx]#.T
plt.imshow(reconstruct1,cmap='gray')
plt.axis('off')
#plt.show()
plt.savefig('processedframes/'+'rpca_cat_'+str(figidx)+'.png', bbox_inches='tight')
else:
U, V, lv = personalized_pca_dgd(Y, args=args)
for figidx in range(len(Y)):
print('saving image {}'.format(figidx))
Ui, Vi = generalized_retract(U[figidx], V[figidx])
reconstruct0 = (Vi@Vi.T@Y[figidx].T)#.T
plt.imshow(reconstruct0,cmap='gray')
plt.axis('off')
plt.savefig('processedframes/'+'cat_'+str(figidx)+'.png', bbox_inches='tight')
reconstruct1 = (Ui@Ui.T @ Y[figidx].T)#.T
plt.imshow(reconstruct1,cmap='gray')
plt.axis('off')
#plt.show()
plt.savefig('processedframes/'+'bg_'+str(figidx)+'.png', bbox_inches='tight')
plt.imshow(reconstruct0+reconstruct1,cmap='gray')
plt.axis('off')
plt.savefig('processedframes/'+'full_'+str(figidx)+'.png', bbox_inches='tight')
def debate_test(inputargs):
args = {
'method': 'power',
'd': 100,
'num_client': 4,
'nlc': 2,
'ngc': 2,
'num_dp_per_client': 100,
'global_epochs': 20,
'local_epochs': 1,
'n_power': 1,
'eta': 1e0,
'rho': 100,
'lambda': 0,
'decay': 1 - 0.1,
'logprogress':1,
#'precise':1,
}
np.random.seed(2021)
print(args)
from vectorize import vectorize_words, top_words
Y, number2word, allyears = vectorize_words()
print('data loaded')
print('number of elections %d'%len(Y))
print('number of dialogues %d'%sum([len(Y[i]) for i in range(len(Y))]))
args['num_client'] = len(Y)
args['d'] = len(Y[0][0])
args['num_dp_per_client'] = len(Y[0])
U_glb = initial_u(Y, d=args['d'], ngc=args['nlc'] + args['ngc'])
print(U_glb.shape)
reconstruct0 = (U_glb @ U_glb.T @ (Y[0].T)).T
Y_test = copy.deepcopy(Y) # generate_data(g_cs=gcs, l_cs=lcs, d=args['d'], num_dp=args['num_dp_per_client'])
print('global model test loss:')
print(loss(Y_test, U_glb))
U, V, lv = personalized_pca_dgd(Y, args=args)
for yearidx in range(len(Y)):
Ui, Vi = generalized_retract(U[yearidx], V[yearidx])
print('year %d :'% allyears[yearidx])
words = []
for j in range(args['nlc']):
words += top_words(Vi[:,j], number2word, top=10)
print(list(set(words)))
print('common words:')
words = []
for j in range(args['ngc']):
words += top_words(Ui[:,j], number2word, top=10)
print(list(set(words)))
def femnist_test(inputargs):
args = {
'method': 'power',
'd': 100,
'num_client': 4,
'nlc': 5,
'ngc': 50,
'num_dp_per_client': 100,
'global_epochs': 50,
'local_epochs': 50,
'n_power': 1,
'eta': 1,
'rho': 100,
'lambda': 0,
'decay': 1 - 0.1,
'logprogress':1,
'aggregationinit':1,
}
np.random.seed(4)
from mnist import femnist_images, femnist_images_labels
Y, Y_test, lbtrain, lbtest = femnist_images_labels()
args['num_client'] = len(Y)
args['d'] = len(Y[0][0])
args['num_dp_per_client'] = len(Y[0])
U_glb = initial_u(Y, d=args['d'], ngc=args['nlc'] + args['ngc'])
print(U_glb.shape)
import imgpro
print('global model train loss:')
print(loss(Y, U_glb))
print('global model test loss:')
print(loss(Y_test, U_glb))
# logistic regression
Yr = [U_glb.T@Yi.T for Yi in Y]
Yrtest = [U_glb.T@Yi.T for Yi in Y_test]
lpcs = [single_PCA(Yi, args['nlc']+args['ngc']) for Yi in Y]
singletestloss = np.array([single_loss(Y_test[i], lpcs[i]) for i in range(len(Y_test))])
print('indiv PCA model test loss: %.4f'%(np.mean(singletestloss[:len(singletestloss)])))
singletestloss = np.array([single_loss(Y[i], lpcs[i]) for i in range(len(Y_test))])
print('indiv PCA model train loss: %.4f'%(np.mean(singletestloss[:len(singletestloss)])))
def intro_example(inputargs):
args = {
'method':'power',
'd':3,
'num_client':2,
'nlc':1,
'ngc':1,
'num_dp_per_client':100,
'global_epochs':1000,
'n_power':1,
'eta':0.1,
'rho':1,
'decay':1-0.05,
'logprogress':1,
}
#num_client=20
np.random.seed(2021)
gcs = np.array([[0,0,1]])
theta = 30/180*np.pi
lcs = np.array([[[np.cos(theta/2),np.sin(theta/2),0]],[[np.cos(theta/2),-np.sin(theta/2),0]]])
gsigma = 1
lsigma = 2
theta1 = np.random.rand(args['num_dp_per_client'])*2*np.pi
theta1 = theta1.reshape(len(theta1),1)
Y1 = gsigma*np.cos(theta1)*gcs+lsigma*np.sin(theta1)*lcs[0]
theta2 = np.random.rand(args['num_dp_per_client'])*2*np.pi
theta2 = theta1.reshape(len(theta2),1)
Y2 = gsigma*np.cos(theta2)*gcs+lsigma*np.sin(theta2)*lcs[1]
fig = plt.figure()
ax = fig.add_subplot(projection='3d')
ax.scatter(Y1[:,0], Y1[:,1], Y1[:,2], color='red')
ax.scatter(Y2[:,0], Y2[:,1], Y2[:,2], color='blue',alpha=0.5)
#Y = np.stack((Y1,Y2))
U_glb = initial_u([Y1,Y2], d=args['d'], ngc=args['nlc']+args['ngc'])
UNIFORM = True
scale = 2.1
U_glb *= scale
if UNIFORM:
for i in range(2):
if U_glb[2, i] < 0:
U_glb[:,i] *= -1
ax.quiver(
0, 0, 0, # <-- starting point of vector
U_glb[0,i], U_glb[1,i], U_glb[2,i], # <-- directions of vector
color='black', alpha=1., lw=2, label='global component {}'.format(i+1),
)
else:
U, V, lv = personalized_pca_dgd([Y1,Y2], args=args)
U = [ui*scale for ui in U]
V = [vi*scale for vi in V]
#print(U)
if U[0][2,0]<0:
U[0] *= -1
ax.quiver(
0, 0, 0, # <-- starting point of vector
U[0][0,0], U[0][1,0], U[0][2,0], # <-- directions of vector
color='black', alpha=1., lw=2, label='global component'
)
if V[0][2,0]<0:
V[0] *= -1
ax.quiver(
0, 0, 0, # <-- starting point of vector
V[0][0, 0], V[0][1, 0], V[0][2, 0], # <-- directions of vector
color='red', alpha=1., lw=2, label='node 1\'s local component',
)
if V[1][2,0]<0:
V[1] *= -1
ax.quiver(
0, 0, 0, # <-- starting point of vector
V[1][0, 0], V[1][1, 0], V[1][2, 0], # <-- directions of vector
color='blue', alpha=1., lw=2, label='node 2\'s local component',
)
ax.set_xlim3d(-2.5, 2.5)
ax.set_ylim3d(-1.5, 1.5)
ax.set_zlim3d(-2.01, 2.01)
ax.view_init(40, -50)
plt.legend(prop={'size': 14})
plt.savefig('intro_example_ppca_{}.png'.format(not UNIFORM),bbox_inches='tight')
def toy_example1(inputargs):
import json
args = {
'd': 3,
'num_client': 2,
'nlc': 1,
'ngc': 1,
'num_dp_per_client': 100,
'global_epochs': 100,
'choice1':1,
#'adaptivestepsize':1,
#'n_power': 1,
'eta': 1e-0,
'rho': 1,
'decay': 1 - 0.05,
'randominit':1,
}
# num_client=20
num_runs = 10
np.random.seed(2021)
gcs = np.array([[0, 0, 1]])
resdict = {}
for alpha in np.linspace(1,90,100):
resdict[alpha] = []
for number in range(num_runs):
theta = alpha / 180 * np.pi
lcs = np.array([[[np.cos(theta / 2), np.sin(theta / 2), 0]], [[np.cos(theta / 2), -np.sin(theta / 2), 0]]])
gsigma = 1
lsigma = 2
theta1 = np.random.rand(args['num_dp_per_client']) * 2 * np.pi
theta1 = theta1.reshape(len(theta1), 1)
# Y has dimension (n_client, num_dp, d)
Y1 = gsigma * np.cos(theta1) * gcs + lsigma * np.sin(theta1) * lcs[0]
theta2 = np.random.rand(args['num_dp_per_client']) * 2 * np.pi
theta2 = theta1.reshape(len(theta2), 1)
Y2 = gsigma * np.cos(theta2) * gcs + lsigma * np.sin(theta2) * lcs[1]
Y = np.stack((Y1, Y2))
#U_glb = initial_u(Y, d=args['d'], ngc=args['nlc'] + args['ngc'])
#scale = 2.1
#U_glb *= scale
U, V, lv = personalized_pca_dgd(Y, args=args)
resdict[alpha].append(lv)
resdict[alpha] = np.stack(resdict[alpha])
tv = []
lv = []
dev = []
for alpha in resdict:
ar = alpha / 180 * np.pi
theta = 1-np.cos(ar/2)
tv.append(theta)
lv.append(np.mean(np.log(resdict[alpha]), axis=0)[-1]/np.log(10))
dev.append(np.std(np.log(resdict[alpha]), axis=0)[-1]/np.log(10)/np.sqrt(num_runs))
lv = np.array(lv)
dev = np.array(dev)
from plotall import CD
plt.plot(tv, lv, color='red')
#plt.scatter(tv, lv, color = CD['ppca'])
#plt.plot(tv, lv, color=CD['ppca'],linestyle='--', label='Personalized PCA')
plt.fill_between(tv, lv-1.732*dev, lv+1.732*dev, alpha=0.5)
plt.xlabel(r'$\theta$',fontsize=20)
plt.ylabel('log reconstruction error',fontsize=20)
#plt.title('Log training reconstruction error after {} rounds'.format(args['global_epochs']),fontsize=20)
#plt.legend(fontsize=20)
plt.savefig('logerrortotheta.png', bbox_inches='tight')
def toy_example2(inputargs):
args = {
'd': 3,
'num_client': 2,
'nlc': 1,
'ngc': 1,
'num_dp_per_client': 100,
'global_epochs': 100,
'choice1':1,
#'adaptivestepsize':1,
#'n_power': 1,
'eta': 1e-0,
'rho': 1,
'decay': 1 - 0.05,
'randominit':1,
'alpha':60,
}
# num_client=20
num_runs = 1
np.random.seed(2021)
gcs = np.array([[0, 0, 1]])
color1 = np.array([0.8, 0., 0.])
color2 = np.array([0., 0.8, 0.8])
dcolor = (color2-color1)*0.5
for alpha in range(10,100,10):
resdict = []
for number in range(num_runs):
theta = alpha / 180 * np.pi
lcs = np.array([[[np.cos(theta / 2), np.sin(theta / 2), 0]], [[np.cos(theta / 2), -np.sin(theta / 2), 0]]])
gsigma = 1
lsigma = 2
theta1 = np.random.rand(args['num_dp_per_client']) * 2 * np.pi
theta1 = theta1.reshape(len(theta1), 1)
# Y has dimension (n_client, num_dp, d)
Y1 = gsigma * np.cos(theta1) * gcs + lsigma * np.sin(theta1) * lcs[0]
theta2 = np.random.rand(args['num_dp_per_client']) * 2 * np.pi
theta2 = theta1.reshape(len(theta2), 1)
Y2 = gsigma * np.cos(theta2) * gcs + lsigma * np.sin(theta2) * lcs[1]
Y = np.stack((Y1, Y2))
U, V, lv = personalized_pca_dgd(Y, args=args)
resdict.append(lv)
resdict = np.stack(resdict)
lv = np.mean(np.log(resdict), axis=0)/np.log(10)
rounds = np.arange(len(lv))
plt.plot(rounds, lv, color=color1+theta*dcolor, label='$\theta$=%.2f'%theta)
from plotall import CD
plt.xlabel(r'Communication round',fontsize=20)
plt.ylabel('log reconstruction error',fontsize=20)
plt.savefig('logerrortoround.png', bbox_inches='tight')
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser(description='personalized pca')
parser.add_argument('--dataset', type=str, default="borrowpowertest")
parser.add_argument('--algorithm', type=str, default="dgd")
parser.add_argument('--logoutput', type=bool, default=False)
parser.add_argument('--seed', type=int, default=2022)
parser.add_argument('--d', type=int, default=15)
parser.add_argument('--num_client', type=int, default=100)
parser.add_argument('--nlc', type=int, default=10)
parser.add_argument('--ngc', type=int, default=2)
parser.add_argument('--num_dp_per_client', type=int, default=1000)
parser.add_argument('--folderprefix', type=str, default='')
args = parser.parse_args()
args = vars(args)
if args['logoutput']:
from misc import Tee
import time
import sys
output_dir = args['folderprefix']+'outputs/{}_'.format(args['dataset'])
jour = time.strftime("%Y-%m-%d-jour-%H-%M-%S", time.localtime())
output_dir += jour
os.makedirs(output_dir, exist_ok=True)
sys.stdout = Tee(os.path.join(output_dir, 'out.txt'))
experiment = getattr(Experiment, args['dataset'])
experiment(args)