-
Notifications
You must be signed in to change notification settings - Fork 5
/
run_mimify_GAN.py
124 lines (106 loc) · 3.9 KB
/
run_mimify_GAN.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
from CCIT import *
import numpy as np
import pandas as pd
from src.MIMIFY_GAN import *
from src.MIMIFY_REG import *
import argparse
def get_args():
parser = argparse.ArgumentParser(
description='runs CI test from a folder')
# Add arguments
parser.add_argument(
'-fp', '--folder_path', type=str, help='Data Folder Path', required=True)
parser.add_argument(
'-dx', '--dimX', type=int, help='dimension of X', required=True)
parser.add_argument(
'-dy', '--dimY', type=int, help='dimension of Y', required=True)
parser.add_argument(
'-dz', '--dimZ', type=int, help='dimension of X', required=True)
parser.add_argument(
'-dn', '--dimN', type=int, help='dimension of noise', required=False)
parser.add_argument(
'-nf', '--numfile', type=int, help='number of files', required=True)
parser.add_argument(
'-nt', '--nthread', type=int, help='number of threads', required=False)
parser.add_argument(
'-me', '--maxepoch', type=int, help='max. number of epochs to train regressor', required=False)
parser.add_argument(
'-bs', '--bsize', type=int, help='batch size', required=False)
parser.add_argument(
'-rf', '--rfile', type=str, help='result file name', required=True)
parser.add_argument(
'-nm', '--normalized', type=int, help='normalize data-set?', required=True)
parser.add_argument(
'-dm', '--dim', type=int, help='hidden size of regressor', required=False)
parser.add_argument(
'-dc', '--deepclassifier', type=int, help='1 if deep classifier, 0 if xgb', required=True)
parser.add_argument(
'-nh', '--nhid', type=int, help='number of neurons in hidden layer of deep classifier', required=False)
parser.add_argument(
'-nl', '--nlayers', type=int, help='number of layers in deep classifier', required=False)
parser.add_argument(
'-dr', '--dropout', type=float, help='dropout in deep classifier', required=False)
# Array for all arguments passed to script
args = parser.parse_args()
folder_path = args.folder_path
dx = args.dimX
dy = args.dimY
dz = args.dimZ
numfile = args.numfile
if args.nthread:
nthread = args.nthread
else:
nthread = 16
if args.dimN:
dimN = args.dimN
else:
dimN = 30
if args.maxepoch:
maxepoch = args.maxepoch
else:
maxepoch = 50
if args.bsize:
bsize = args.bsize
else:
bsize = 50
rfile = args.rfile
normalized = args.normalized
dc = args.deepclassifier
if args.nhid:
nh = args.nhid
else:
nh = 20
if args.nlayers:
nl = args.nlayers
else:
nl = 5
if args.dropout:
dr = args.dropout
else:
dr = 0.2
return folder_path,dx,dy,dz,numfile,nthread,dimN,maxepoch,bsize,rfile,normalized,dc,nh,nl,dr
if __name__ == "__main__":
folder_path,dx,dy,dz,numfile,nthread,dim_N,maxepoch,bsize,rfile,normalized,dc,nh,nl,dr = get_args()
if normalized == 1:
temp = True
else:
temp = False
if dc == 1:
deepclassifier = True
else:
deepclassifier = False
normalized = temp
params = {'nhid':nh,'nlayers':nl,'dropout':dr}
pvalues = []
d = np.load(folder_path + 'datafile.npy')
for i in range(numfile):
print '#iter: ' + str(i)
datafile = folder_path + 'datafile' + str(i) + '_' + str(dz) + '.csv'
y = pd.read_csv(datafile,header = None)
y = np.array(y).astype(np.float32)
y = y[1::,1::]
MCG = MIMIFY_GAN(y[:,0:dx],y[:,dx:dx+dy],y[:,dx+dy:dx+dy+dz],\
normalized=normalized,nthread = nthread, dim_N = dim_N, max_epoch = maxepoch, bsize = bsize,deep_classifier=deepclassifier,params = params)
pvalues = pvalues + [MCG.CI_classify()]
print i,d[i],pvalues[-1]
np.save(folder_path + rfile + '.npy' ,pvalues)