-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathmain_run.py
More file actions
285 lines (250 loc) · 8.58 KB
/
main_run.py
File metadata and controls
285 lines (250 loc) · 8.58 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
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
# THIS IS THE SECOND PART OF TWO MAIN PROGRAMS IN THIS PROJECT.
# THE OTHER ONE BEING THE MAIN_DOWNLOAD.PY
# HERE YOU RUN THE TRAINING PROGRAM OF THE MULTIMODAL DEEP BELIEF NETWORK (MDBN)
# YOU WILL DESIGN YOUR OWN NETWORK
import sys
import os
import timeit
import argparse
DATASET = 6
PRETRAIN_EPOCH = 100
TRAIN_EPOCH = 100
BATCH_SIZE = 10
PRETRAIN_LR = 0.01
TRAIN_LR = 0.1
LAYERS = []
LAYERS_MET = []
LAYERS_GEN = []
LAYERS_MIR = []
LAYERS_TOT = []
DROPOUT = 0.2
PCA = 2
OPTIMIZER = 1
def main():
global DATASET
global PRETRAIN_EPOCH
global TRAIN_EPOCH
global BATCH_SIZE
global PRETRAIN_LR
global TRAIN_LR
global LAYERS
global DROPOUT
global PCA
global OPTIMIZER
print("Welcome to mDBN breast cancer status prediction!")
print("All training data by TCGA BRCA\n")
parser = argparse.ArgumentParser()
requiredArgs = parser.add_argument_group('required arguments')
requiredArgs.add_argument("-p", "--platform", type=int, help="Platform to be used [1-2]", required=True)
requiredArgs.add_argument("-t", "--type", type=int, help="Types of prediction [1-2]", required=True)
requiredArgs.add_argument("-d", "--dataset", type=int, help="Dataset of TCGA BRCA to be used [1-15]", required=True)
parser.add_argument("--pretrain_epoch", type=int, help="Pretrain for specified epochs")
parser.add_argument("--train_epoch", type=int, help="Train for specified epochs")
parser.add_argument("--batch_size", type=int, help="Pretraining and training batch size")
parser.add_argument("--pretrain_lr", type=int, help="Pretraining learning rate")
parser.add_argument("--train_lr", type=int, help="Training learning rate")
parser.add_argument("--dropout", type=int, help="Dropout rate")
parser.add_argument("--pca", type=int, help="PCA usage [1-2]")
parser.add_argument("--optimizer", type=int, help="Type of optimizer to be used [1-3]")
args = parser.parse_args()
platform = int(args.platform)
prediction = int(args.type)
DATASET = int(args.dataset)
if args.pretrain_epoch:
PRETRAIN_EPOCH = int(args.pretrain_epoch)
if args.train_epoch:
TRAIN_EPOCH = int(args.train_epoch)
if args.batch_size:
BATCH_SIZE = int(args.batch_size)
if args.pretrain_lr:
PRETRAIN_LR = int(args.pretrain_lr)
if args.train_lr:
TRAIN_LR = int(args.train_lr)
if args.dropout:
DROPOUT = int(args.dropout)
if args.pca:
PCA = int(args.pca)
if args.optimizer:
OPTIMIZER = int(args.optimizer)
######################
####### LAYERS #######
######################
print("Neural Network Layers")
if (DATASET >= 1) and (DATASET <= 6):
try:
n_layers = int(input("Number of hidden layers [default = 3]: "))
except Exception as e:
n_layers = 3
for i in range(n_layers):
try:
temp = int(input("Layer " + str(i) + " size [default = 1000]: "))
except Exception as e:
temp = 1000
LAYERS.append(temp)
elif (DATASET >= 7) and (DATASET <= 15):
if (DATASET >= 10) and (DATASET <= 15):
try:
n_layers = int(input("Number of hidden layers for DNA-Methylation's DBN [default = 3]: "))
except Exception as e:
n_layers = 3
for i in range(n_layers):
try:
temp = int(input("Layer " + str(i) + " size [default = 1000]: "))
except Exception as e:
temp = 1000
LAYERS_MET.append(temp)
try:
n_layers = int(input("Number of hidden layers for Gene-Expression's DBN [default = 3]: "))
except Exception as e:
n_layers = 3
for i in range(n_layers):
try:
temp = int(input("Layer " + str(i) + " size [default = 1000]: "))
except Exception as e:
temp = 1000
LAYERS_GEN.append(temp)
try:
n_layers = int(input("Number of hidden layers for miRNA-Expression's DBN [default = 3]: "))
except Exception as e:
n_layers = 3
for i in range(n_layers):
try:
temp = int(input("Layer " + str(i) + " size [default = 1000]: "))
except Exception as e:
temp = 1000
LAYERS_MIR.append(temp)
try:
n_layers = int(input("Number of hidden layers for combined DBN [default = 3]: "))
except Exception as e:
n_layers = 3
for i in range(n_layers):
try:
temp = int(input("Layer " + str(i) + " size [default = 500]: "))
except Exception as e:
temp = 500
LAYERS_TOT.append(temp)
######################
#### OPEN PROGRAM ####
######################
start = timeit.default_timer()
program_path = os.path.dirname(os.path.realpath(__file__))
if platform == 1: # 1. Tensorflow
sys.path.insert(0, program_path + '/Tensorflow')
if prediction == 1: # 1.1. Tensorflow Classification
if (DATASET >= 1) and (DATASET <= 6): # 1.1.1. Tensorflow Classification DBN
from DBN_classification import test_DBN
test_DBN(dataset = DATASET,
pretraining_epochs = PRETRAIN_EPOCH,
training_epochs = TRAIN_EPOCH,
pretrain_lr = PRETRAIN_LR,
finetune_lr = TRAIN_LR,
batch_size = BATCH_SIZE,
layers=LAYERS,
dropout=DROPOUT,
pca=PCA,
optimizer=OPTIMIZER)
elif (DATASET >= 7) and (DATASET <= 15): # 1.1.2 Tensorflow Classification mDBN
from mDBN_classification import test_mDBN
test_mDBN(dataset = DATASET,
pretraining_epochs = PRETRAIN_EPOCH,
training_epochs = TRAIN_EPOCH,
pretrain_lr = PRETRAIN_LR,
finetune_lr = TRAIN_LR,
batch_size = BATCH_SIZE,
layers_met=LAYERS_MET,
layers_gen=LAYERS_GEN,
layers_mir=LAYERS_MIR,
layers_tot=LAYERS_TOT,
dropout=DROPOUT,
pca=PCA,
optimizer=OPTIMIZER)
elif prediction == 2: # 1.2. Tensorflow Regression
if (DATASET >= 1) and (DATASET <= 6): # 1.2.1. Tensorflow Regression DBN
from DBN_regression import test_DBN
test_DBN(dataset = DATASET,
pretraining_epochs = PRETRAIN_EPOCH,
training_epochs = TRAIN_EPOCH,
pretrain_lr = PRETRAIN_LR,
finetune_lr = TRAIN_LR,
batch_size = BATCH_SIZE,
layers=LAYERS,
dropout=DROPOUT,
pca=PCA,
optimizer=OPTIMIZER)
elif (DATASET >= 7) and (DATASET <= 15): # 1.2.2. Tensorflow Regression mDBN
from mDBN_regression import test_mDBN
test_mDBN(dataset = DATASET,
pretraining_epochs = PRETRAIN_EPOCH,
training_epochs = TRAIN_EPOCH,
pretrain_lr = PRETRAIN_LR,
finetune_lr = TRAIN_LR,
batch_size = BATCH_SIZE,
layers_met=LAYERS_MET,
layers_gen=LAYERS_GEN,
layers_mir=LAYERS_MIR,
layers_tot=LAYERS_TOT,
dropout=DROPOUT,
pca=PCA,
optimizer=OPTIMIZER)
elif platform == 2: # 2. Theano
sys.path.insert(0, program_path + '/Theano')
if prediction == 1: # 2.1. Theano Classification
if (DATASET >= 1) and (DATASET <= 6): # 2.1.1. Theano Classification DBN
from DBN_classification import test_DBN
test_DBN(dataset = DATASET,
pretraining_epochs = PRETRAIN_EPOCH,
training_epochs = TRAIN_EPOCH,
pretrain_lr = PRETRAIN_LR,
finetune_lr = TRAIN_LR,
batch_size = BATCH_SIZE,
layers=LAYERS,
dropout=DROPOUT,
pca=PCA,
optimizer=OPTIMIZER)
elif (DATASET >= 7) and (DATASET <= 15): # 2.1.2. Theano Classification mDBN
from mDBN_classification import test_mDBN
test_mDBN(dataset = DATASET,
pretraining_epochs = PRETRAIN_EPOCH,
training_epochs = TRAIN_EPOCH,
pretrain_lr = PRETRAIN_LR,
finetune_lr = TRAIN_LR,
batch_size = BATCH_SIZE,
layers_met=LAYERS_MET,
layers_gen=LAYERS_GEN,
layers_mir=LAYERS_MIR,
layers_tot=LAYERS_TOT,
dropout=DROPOUT,
pca=PCA,
optimizer=OPTIMIZER)
elif prediction == 2: # 2.2. Theano Regression
if (DATASET >= 1) and (DATASET <= 6): # 2.2.1. Theano Regression DBN
from DBN_regression import test_DBN
test_DBN(dataset = DATASET,
pretraining_epochs = PRETRAIN_EPOCH,
training_epochs = TRAIN_EPOCH,
pretrain_lr = PRETRAIN_LR,
finetune_lr = TRAIN_LR,
batch_size = BATCH_SIZE,
layers=LAYERS,
dropout=DROPOUT,
pca=PCA,
optimizer=OPTIMIZER)
elif (DATASET >= 7) and (DATASET <= 15): # 2.2.2. Theano Regression mDBN
from mDBN_regression import test_mDBN
test_mDBN(dataset = DATASET,
pretraining_epochs = PRETRAIN_EPOCH,
training_epochs = TRAIN_EPOCH,
pretrain_lr = PRETRAIN_LR,
finetune_lr = TRAIN_LR,
batch_size = BATCH_SIZE,
layers_met=LAYERS_MET,
layers_gen=LAYERS_GEN,
layers_mir=LAYERS_MIR,
layers_tot=LAYERS_TOT,
dropout=DROPOUT,
pca=PCA,
optimizer=OPTIMIZER)
stop = timeit.default_timer()
print("\nOverall the program run for: " + str(stop-start) + "s")
if __name__ == '__main__':
main()