Skip to content

Commit c1e69b7

Browse files
committed
Added missing keyword definitions, fixed broken model files, made args consistent.
1 parent 24c88cf commit c1e69b7

File tree

5 files changed

+38
-18
lines changed

5 files changed

+38
-18
lines changed

Pilot2/P2B1/p2b1.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,27 @@
3131
{'name':'train_bool', 'type':candle.str2bool,'default':True,'help':'Invoke training'},
3232
{'name':'eval_bool', 'type':candle.str2bool,'default':False,'help':'Use model for inference'},
3333
{'name':'home_dir','help':'Home Directory','type':str,'default':'.'},
34-
{'name':'config_file','help':'Config File','type':str,'default':os.path.join(file_path, 'p2b1_default_model.txt')},
34+
#{'name':'config_file','help':'Config File','type':str,'default':os.path.join(file_path, 'p2b1_default_model.txt')},
3535
{'name':'weight_path','help':'Trained Model Pickle File','type':str,'default':None},
3636
{'name':'base_memo','help':'Memo','type':str,'default':None},
37-
{'name':'seed', 'type':candle.str2bool,'default':False,'help':'Random Seed'},
37+
#{'name':'seed_bool', 'type':candle.str2bool,'default':False,'help':'Random Seed'},
3838
{'name':'case','help':'[Full, Center, CenterZ]','type':str,'default':'Full'},
3939
{'name':'fig_bool', 'type':candle.str2bool,'default':False,'help':'Generate Prediction Figure'},
4040
{'name':'set_sel','help':'[3k_Disordered, 3k_Ordered, 3k_Ordered_and_gel, 6k_Disordered, 6k_Ordered, 6k_Ordered_and_gel]','type':str,'default':'3k_Disordered'},
4141
{'name':'conv_bool', 'type':candle.str2bool, 'default':True, 'help':'Invoke training using 1D Convs for inner AE'},
4242
{'name':'full_conv_bool', 'type':candle.str2bool, 'default':False, 'help':'Invoke training using fully convolutional NN for inner AE'},
4343
{'name':'type_bool', 'type':candle.str2bool, 'default':True, 'help':'Include molecule type information in desining AE'},
4444
{'name':'nbr_type', 'type':str, 'default':'relative', 'help':'Defines the type of neighborhood data to use. [relative, invariant]'},
45-
{'name':'backend', 'help':'Keras Backend', 'type':str, 'default':'tensorflow'}
45+
{'name':'backend', 'help':'Keras Backend', 'type':str, 'default':'tensorflow'},
46+
{'name':'cool', 'help':'Boolean: cool learning rate', 'type':candle.str2bool, 'default':False},
47+
{'name':'data_set', 'help':'Data set for training', 'type':str, 'default':None},
48+
{'name':'l2_reg', 'help':'Regularization parameter', 'type':float, 'default':None},
49+
{'name':'molecular_nbrs', 'help':'Data dimension for molecular autoencoder', 'type':int, 'default':None},
50+
{'name':'molecular_nonlinearity', 'help':'Activation for molecular netowrk', 'type':str, 'default':None},
51+
{'name':'molecular_num_hidden', 'nargs':'+', 'help':'Layer sizes for molecular network', 'type':int, 'default':None},
52+
{'name':'noise_factor', 'help':'Noise factor', 'type':float, 'default':None},
53+
{'name':'num_hidden', 'nargs':'+', 'help':'Dense layer specification', 'type':int, 'default':None},
54+
{'name':'sampling_density', 'help':'Sampling density', 'type':float, 'default':None}
4655
]
4756

4857
required = [
@@ -61,7 +70,7 @@
6170
'molecular_num_hidden',
6271
'molecular_nonlinearity',
6372
'molecular_nbrs',
64-
'drop_prob',
73+
'dropout',
6574
'l2_reg',
6675
'sampling_density',
6776
'save_path'

Pilot2/P2B1/p2b1_baseline_keras2.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from importlib import reload # Python 3.4+
1313
except ImportError:
1414
from imp import reload # Python 3.0 - 3.3
15-
15+
1616
TIMEOUT=3600 # in sec; set this to -1 for no timeout
1717
file_path = os.path.dirname(os.path.realpath(__file__))
1818
#lib_path = os.path.abspath(os.path.join(file_path, '..', 'common'))
@@ -22,7 +22,7 @@
2222

2323
from keras import backend as K
2424

25-
import p2b1
25+
import p2b1
2626
import candle
2727

2828
import p2b1_AE_models as AE_models
@@ -53,7 +53,7 @@ def initialize_parameters(default_model = 'p2b1_default_model.txt'):
5353
print ('\nTraining parameters:')
5454
for key in sorted(GP):
5555
print ("\t%s: %s" % (key, GP[key]))
56-
56+
5757
# print json.dumps(GP, indent=4, skipkeys=True, sort_keys=True)
5858

5959
if GP['backend'] != 'theano' and GP['backend'] != 'tensorflow':
@@ -79,8 +79,8 @@ def initialize_parameters(default_model = 'p2b1_default_model.txt'):
7979
def run(GP):
8080

8181
# set the seed
82-
if GP['seed']:
83-
np.random.seed(GP['seed'])
82+
if GP['rng_seed']:
83+
np.random.seed(GP['rng_seed'])
8484
else:
8585
np.random.seed(np.random.randint(10000))
8686

@@ -211,7 +211,7 @@ def run(GP):
211211
nonlinearity=molecular_nonlinearity,
212212
hidden_layers=molecular_hidden_layers,
213213
l2_reg=GP['l2_reg'],
214-
drop=float(GP['drop_prob']))
214+
drop=float(GP['dropout']))
215215
elif full_conv_bool:
216216
molecular_model, molecular_encoder = AE_models.full_conv_mol_auto(bead_k_size=bead_kernel_size,
217217
mol_k_size=mol_kernel_size,
@@ -220,14 +220,14 @@ def run(GP):
220220
nonlinearity=molecular_nonlinearity,
221221
hidden_layers=molecular_hidden_layers,
222222
l2_reg=GP['l2_reg'],
223-
drop=float(GP['drop_prob']))
223+
drop=float(GP['dropout']))
224224

225225
else:
226226
molecular_model, molecular_encoder = AE_models.dense_auto(weights_path=None, input_shape=(molecular_input_dim,),
227227
nonlinearity=molecular_nonlinearity,
228228
hidden_layers=molecular_hidden_layers,
229229
l2_reg=GP['l2_reg'],
230-
drop=float(GP['drop_prob']))
230+
drop=float(GP['dropout']))
231231

232232
if GP['loss'] == 'mse':
233233
loss_func = 'mse'
@@ -238,7 +238,7 @@ def run(GP):
238238
print ('\nModel Summary: \n')
239239
molecular_model.summary()
240240
##### set up callbacks and cooling for the molecular_model ##########
241-
drop = 0.5
241+
drop = GP['dropout']
242242
mb_epochs = GP['epochs']
243243
initial_lrate = GP['learning_rate']
244244
epochs_drop = 1+int(np.floor(mb_epochs/3))

Pilot2/P2B1/p2b1_default_model.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ molecular_nonlinearity='elu'
1313
molecular_num_hidden=[256, 128, 64, 32, 16, 8]
1414
molecular_nbrs = 200
1515
base_memo='p2b1'
16-
drop_prob = 0.5
16+
dropout = 0.5
1717
data_set='3k_Ordered'
1818
sampling_density = 0.15
1919
save_path='.'

Pilot2/P2B1/p2b1_medium_model.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ batch_size=32
44
learning_rate=0.01
55
epochs=10
66
cool=True
7-
weight_decay=0.0005
7+
optimizer='adam'
8+
loss='custom'
9+
activation='relu'
10+
molecular_nonlinearity='elu'
11+
molecular_num_hidden=[256, 128, 64, 32, 16, 8]
12+
molecular_nbrs = 200
813
noise_factor=0
914
base_memo='p2b1'
15+
dropout = 0.5
16+
l2_reg=0.01
17+
sampling_density = 0.15
18+
save_path='.'

Pilot2/P2B1/p2b1_small_model.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ batch_size=32
44
learning_rate=0.01
55
epochs=10
66
cool=False
7-
weight_decay=0.0005
87
noise_factor=0.0
98
optimizer='adam'
109
loss='mse'
1110
activation='relu'
12-
molecular_nonlinearity=elu
11+
molecular_nonlinearity='elu'
1312
molecular_num_hidden=[54,12]
14-
molecular_epochs=1
1513
molecular_nbrs=10
1614
base_memo='p2b1'
15+
dropout = 0.5
16+
l2_reg=0.01
17+
sampling_density = 0.15
18+
save_path='.'

0 commit comments

Comments
 (0)