Skip to content

Commit fc750f7

Browse files
DDI and DTI tested; release 0.1.2
1 parent 8d93b94 commit fc750f7

9 files changed

Lines changed: 232 additions & 60 deletions

File tree

DEMO/GNN_Models_Release_Example.ipynb

Lines changed: 153 additions & 0 deletions
Large diffs are not rendered by default.

DeepPurpose/CompoundPred.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ def __init__(self, **config):
173173
self.model_drug = DGL_GIN_AttrMasking(predictor_dim = config['hidden_dim_drug'])
174174
elif drug_encoding == 'DGL_GIN_ContextPred':
175175
self.model_drug = DGL_GIN_ContextPred(predictor_dim = config['hidden_dim_drug'])
176-
elif drug_encoding == 'AttentiveFP':
177-
self.model_drug = AttentiveFP(node_feat_size = 39,
176+
elif drug_encoding == 'DGL_AttentiveFP':
177+
self.model_drug = DGL_AttentiveFP(node_feat_size = 39,
178178
edge_feat_size = 11,
179179
num_layers = config['gnn_num_layers'],
180180
num_timesteps = config['attentivefp_num_timesteps'],
@@ -203,7 +203,7 @@ def test_(self, data_generator, model, repurposing_mode = False, test = False, v
203203
y_label = []
204204
model.eval()
205205
for i, (v_d, label) in enumerate(data_generator):
206-
if self.drug_encoding in ["MPNN", 'Transformer', 'DGL_GCN', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'AttentiveFP']:
206+
if self.drug_encoding in ["MPNN", 'Transformer', 'DGL_GCN', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'DGL_AttentiveFP']:
207207
v_d = v_d
208208
else:
209209
v_d = v_d.float().to(self.device)
@@ -285,7 +285,7 @@ def train(self, train, val, test = None, verbose = True):
285285
'drop_last': False}
286286
if (self.drug_encoding == "MPNN"):
287287
params['collate_fn'] = mpnn_collate_func
288-
elif self.drug_encoding in ['DGL_GCN', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'AttentiveFP']:
288+
elif self.drug_encoding in ['DGL_GCN', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'DGL_AttentiveFP']:
289289
params['collate_fn'] = dgl_collate_func
290290

291291
training_generator = data.DataLoader(data_process_loader_Property_Prediction(train.index.values,
@@ -307,7 +307,7 @@ def train(self, train, val, test = None, verbose = True):
307307

308308
if (self.drug_encoding == "MPNN"):
309309
params_test['collate_fn'] = mpnn_collate_func
310-
elif self.drug_encoding in ['DGL_GCN', 'DGL_GAT', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'AttentiveFP']:
310+
elif self.drug_encoding in ['DGL_GCN', 'DGL_GAT', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'DGL_AttentiveFP']:
311311
params_test['collate_fn'] = dgl_collate_func
312312
testing_generator = data.DataLoader(data_process_loader_Property_Prediction(test.index.values, test.Label.values, test, **self.config), **params_test)
313313

@@ -333,7 +333,7 @@ def train(self, train, val, test = None, verbose = True):
333333
for epo in range(train_epoch):
334334
for i, (v_d, label) in enumerate(training_generator):
335335

336-
if self.drug_encoding in ["MPNN", 'Transformer', 'DGL_GCN', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'AttentiveFP']:
336+
if self.drug_encoding in ["MPNN", 'Transformer', 'DGL_GCN', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'DGL_AttentiveFP']:
337337
v_d = v_d
338338
else:
339339
v_d = v_d.float().to(self.device)
@@ -462,7 +462,7 @@ def predict(self, df_data, verbose = True):
462462

463463
if (self.drug_encoding == "MPNN"):
464464
params['collate_fn'] = mpnn_collate_func
465-
elif self.drug_encoding in ['DGL_GCN', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'AttentiveFP']:
465+
elif self.drug_encoding in ['DGL_GCN', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'DGL_AttentiveFP']:
466466
params['collate_fn'] = dgl_collate_func
467467

468468
generator = data.DataLoader(info, **params)

DeepPurpose/DDI.py

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -63,35 +63,12 @@ def model_pretrained(path_dir = None, model = None):
6363
model.load_pretrained(path_dir + '/model.pt')
6464
return model
6565

66-
# def mpnn_feature_collate_func(x):
67-
# ## first version
68-
# return [torch.cat([x[j][i] for j in range(len(x))], 0) for i in range(len(x[0]))]
69-
70-
# def mpnn_feature_collate_func(x):
71-
# assert len(x[0]) == 5
72-
# N_atoms_N_bonds = [i[-1] for i in x]
73-
# N_atoms_scope = []
74-
# f_a = torch.cat([x[j][0] for j in range(len(x))], 0)
75-
# f_b = torch.cat([x[j][1] for j in range(len(x))], 0)
76-
# agraph_lst, bgraph_lst = [], []
77-
# Na, Nb = 0, 0
78-
# for j in range(len(x)):
79-
# agraph_lst.append(x[j][2] + Na)
80-
# bgraph_lst.append(x[j][3] + Nb)
81-
# N_atoms_scope.append([Na, x[j][2].shape[0]])
82-
# Na += x[j][2].shape[0]
83-
# Nb += x[j][3].shape[0]
84-
# agraph = torch.cat(agraph_lst, 0)
85-
# bgraph = torch.cat(bgraph_lst, 0)
86-
# return [f_a, f_b, agraph, bgraph, N_atoms_scope]
87-
88-
# def mpnn_collate_func(x):
89-
# mpnn_feature = [i[0] for i in x]
90-
# mpnn_feature = mpnn_feature_collate_func(mpnn_feature)
91-
# from torch.utils.data.dataloader import default_collate
92-
# x_remain = [[i[1], i[2]] for i in x]
93-
# x_remain_collated = default_collate(x_remain)
94-
# return [mpnn_feature] + x_remain_collated
66+
def dgl_collate_func(x):
67+
d1, d2, y = zip(*x)
68+
import dgl
69+
d1 = dgl.batch(d1)
70+
d2 = dgl.batch(d2)
71+
return d1, d2, torch.tensor(y)
9572

9673
class DDI_Model:
9774

@@ -110,6 +87,31 @@ def __init__(self, **config):
11087
self.model_drug = transformer('drug', **config)
11188
elif drug_encoding == 'MPNN':
11289
self.model_drug = MPNN(config['hidden_dim_drug'], config['mpnn_depth'])
90+
elif drug_encoding == 'DGL_GCN':
91+
self.model_drug = DGL_GCN(in_feats = 74,
92+
hidden_feats = [config['gnn_hid_dim_drug']] * config['gnn_num_layers'],
93+
activation = [config['gnn_activation']] * config['gnn_num_layers'],
94+
predictor_dim = config['hidden_dim_drug'])
95+
elif drug_encoding == 'DGL_NeuralFP':
96+
self.model_drug = DGL_NeuralFP(in_feats = 74,
97+
hidden_feats = [config['gnn_hid_dim_drug']] * config['gnn_num_layers'],
98+
max_degree = config['neuralfp_max_degree'],
99+
activation = [config['gnn_activation']] * config['gnn_num_layers'],
100+
predictor_hidden_size = config['neuralfp_predictor_hid_dim'],
101+
predictor_dim = config['hidden_dim_drug'],
102+
predictor_activation = config['neuralfp_predictor_activation'])
103+
elif drug_encoding == 'DGL_GIN_AttrMasking':
104+
self.model_drug = DGL_GIN_AttrMasking(predictor_dim = config['hidden_dim_drug'])
105+
elif drug_encoding == 'DGL_GIN_ContextPred':
106+
self.model_drug = DGL_GIN_ContextPred(predictor_dim = config['hidden_dim_drug'])
107+
elif drug_encoding == 'DGL_AttentiveFP':
108+
self.model_drug = DGL_AttentiveFP(node_feat_size = 39,
109+
edge_feat_size = 11,
110+
num_layers = config['gnn_num_layers'],
111+
num_timesteps = config['attentivefp_num_timesteps'],
112+
graph_feat_size = config['gnn_hid_dim_drug'],
113+
predictor_dim = config['hidden_dim_drug'])
114+
113115
else:
114116
raise AttributeError('Please use one of the available encoding method.')
115117

@@ -132,7 +134,7 @@ def test_(self, data_generator, model, repurposing_mode = False, test = False):
132134
y_label = []
133135
model.eval()
134136
for i, (v_d, v_p, label) in enumerate(data_generator):
135-
if self.drug_encoding == "MPNN" or self.drug_encoding == 'Transformer':
137+
if self.drug_encoding in ["MPNN", 'Transformer', 'DGL_GCN', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'DGL_AttentiveFP']:
136138
v_d = v_d
137139
v_p = v_p
138140
else:
@@ -206,6 +208,8 @@ def train(self, train, val, test = None, verbose = True):
206208
'drop_last': False}
207209
if (self.drug_encoding == "MPNN"):
208210
params['collate_fn'] = mpnn_collate_func
211+
elif self.drug_encoding in ['DGL_GCN', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'DGL_AttentiveFP']:
212+
params['collate_fn'] = dgl_collate_func
209213

210214
training_generator = data.DataLoader(data_process_DDI_loader(train.index.values, train.Label.values, train, **self.config), **params)
211215
validation_generator = data.DataLoader(data_process_DDI_loader(val.index.values, val.Label.values, val, **self.config), **params)
@@ -220,6 +224,8 @@ def train(self, train, val, test = None, verbose = True):
220224

221225
if (self.drug_encoding == "MPNN"):
222226
params_test['collate_fn'] = mpnn_collate_func
227+
elif self.drug_encoding in ['DGL_GCN', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'DGL_AttentiveFP']:
228+
params_test['collate_fn'] = dgl_collate_func
223229
testing_generator = data.DataLoader(data_process_DDI_loader(test.index.values, test.Label.values, test, **self.config), **params_test)
224230

225231
# early stopping
@@ -242,7 +248,7 @@ def train(self, train, val, test = None, verbose = True):
242248
t_start = time()
243249
for epo in range(train_epoch):
244250
for i, (v_d, v_p, label) in enumerate(training_generator):
245-
if self.drug_encoding == "MPNN" or self.drug_encoding == 'Transformer':
251+
if self.drug_encoding in ["MPNN", 'Transformer', 'DGL_GCN', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'DGL_AttentiveFP']:
246252
v_d = v_d
247253
v_p = v_p
248254
else:
@@ -372,7 +378,8 @@ def predict(self, df_data):
372378

373379
if (self.drug_encoding == "MPNN"):
374380
params['collate_fn'] = mpnn_collate_func
375-
381+
elif self.drug_encoding in ['DGL_GCN', 'DGL_GAT', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'DGL_AttentiveFP']:
382+
params_test['collate_fn'] = dgl_collate_func
376383

377384
generator = data.DataLoader(info, **params)
378385

DeepPurpose/DTI.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,6 @@ def virtual_screening(X_repurpose, target, model, drug_names = None, target_name
212212

213213
def dgl_collate_func(x):
214214
d, p, y = zip(*x)
215-
print(d)
216-
print(p)
217-
print(y)
218215
import dgl
219216
d = dgl.batch(d)
220217
return d, torch.tensor(p), torch.tensor(y)
@@ -256,6 +253,13 @@ def __init__(self, **config):
256253
self.model_drug = DGL_GIN_AttrMasking(predictor_dim = config['hidden_dim_drug'])
257254
elif drug_encoding == 'DGL_GIN_ContextPred':
258255
self.model_drug = DGL_GIN_ContextPred(predictor_dim = config['hidden_dim_drug'])
256+
elif drug_encoding == 'DGL_AttentiveFP':
257+
self.model_drug = DGL_AttentiveFP(node_feat_size = 39,
258+
edge_feat_size = 11,
259+
num_layers = config['gnn_num_layers'],
260+
num_timesteps = config['attentivefp_num_timesteps'],
261+
graph_feat_size = config['gnn_hid_dim_drug'],
262+
predictor_dim = config['hidden_dim_drug'])
259263
else:
260264
raise AttributeError('Please use one of the available encoding method.')
261265

@@ -297,7 +301,7 @@ def test_(self, data_generator, model, repurposing_mode = False, test = False):
297301
y_label = []
298302
model.eval()
299303
for i, (v_d, v_p, label) in enumerate(data_generator):
300-
if self.drug_encoding in ["MPNN", 'Transformer', 'DGL_GCN', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'AttentiveFP']:
304+
if self.drug_encoding in ["MPNN", 'Transformer', 'DGL_GCN', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'DGL_AttentiveFP']:
301305
v_d = v_d
302306
else:
303307
v_d = v_d.float().to(self.device)
@@ -376,7 +380,7 @@ def train(self, train, val = None, test = None, verbose = True):
376380
'drop_last': False}
377381
if (self.drug_encoding == "MPNN"):
378382
params['collate_fn'] = mpnn_collate_func
379-
elif self.drug_encoding in ['DGL_GCN', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'AttentiveFP']:
383+
elif self.drug_encoding in ['DGL_GCN', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'DGL_AttentiveFP']:
380384
params['collate_fn'] = dgl_collate_func
381385

382386
training_generator = data.DataLoader(data_process_loader(train.index.values, train.Label.values, train, **self.config), **params)
@@ -393,7 +397,7 @@ def train(self, train, val = None, test = None, verbose = True):
393397

394398
if (self.drug_encoding == "MPNN"):
395399
params_test['collate_fn'] = mpnn_collate_func
396-
elif self.drug_encoding in ['DGL_GCN', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'AttentiveFP']:
400+
elif self.drug_encoding in ['DGL_GCN', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'DGL_AttentiveFP']:
397401
params_test['collate_fn'] = dgl_collate_func
398402
testing_generator = data.DataLoader(data_process_loader(test.index.values, test.Label.values, test, **self.config), **params_test)
399403

@@ -423,7 +427,7 @@ def train(self, train, val = None, test = None, verbose = True):
423427
v_p = v_p
424428
else:
425429
v_p = v_p.float().to(self.device)
426-
if self.drug_encoding in ["MPNN", 'Transformer', 'DGL_GCN', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'AttentiveFP']:
430+
if self.drug_encoding in ["MPNN", 'Transformer', 'DGL_GCN', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'DGL_AttentiveFP']:
427431
v_d = v_d
428432
else:
429433
v_d = v_d.float().to(self.device)
@@ -563,7 +567,7 @@ def predict(self, df_data):
563567

564568
if (self.drug_encoding == "MPNN"):
565569
params['collate_fn'] = mpnn_collate_func
566-
elif self.drug_encoding in ['DGL_GCN', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'AttentiveFP']:
570+
elif self.drug_encoding in ['DGL_GCN', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'DGL_AttentiveFP']:
567571
params['collate_fn'] = dgl_collate_func
568572

569573
generator = data.DataLoader(info, **params)

DeepPurpose/encoders.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,10 @@ def forward(self, bg):
414414
return self.transform(graph_feats)
415415

416416

417-
class AttentiveFP(nn.Module):
417+
class DGL_AttentiveFP(nn.Module):
418418
## adapted from https://github.com/awslabs/dgl-lifesci/blob/2fbf5fd6aca92675b709b6f1c3bc3c6ad5434e96/python/dgllife/model/model_zoo/attentivefp_predictor.py#L17
419419
def __init__(self, node_feat_size, edge_feat_size, num_layers = 2, num_timesteps = 2, graph_feat_size = 200, predictor_dim=None):
420-
super(AttentiveFP, self).__init__()
420+
super(DGL_AttentiveFP, self).__init__()
421421
from dgllife.model.gnn import AttentiveFPGNN
422422
from dgllife.model.readout import AttentiveFPReadout
423423

DeepPurpose/utils.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ def encode_drug(df_data, drug_encoding, column_name = 'SMILES', save_column_name
397397
df_data[save_column_name] = [unique_dict[i] for i in df_data[column_name]]
398398
elif drug_encoding in ['DGL_GCN', 'DGL_NeuralFP']:
399399
df_data[save_column_name] = df_data[column_name]
400-
elif drug_encoding == 'AttentiveFP':
400+
elif drug_encoding == 'DGL_AttentiveFP':
401401
df_data[save_column_name] = df_data[column_name]
402402
elif drug_encoding in ['DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred']:
403403
df_data[save_column_name] = df_data[column_name]
@@ -632,7 +632,7 @@ def __init__(self, list_IDs, labels, df, **config):
632632
from functools import partial
633633
self.fc = partial(smiles_to_bigraph, add_self_loop=True)
634634

635-
elif self.config['drug_encoding'] == 'AttentiveFP':
635+
elif self.config['drug_encoding'] == 'DGL_AttentiveFP':
636636
from dgllife.utils import smiles_to_bigraph, AttentiveFPAtomFeaturizer, AttentiveFPBondFeaturizer
637637
self.node_featurizer = AttentiveFPAtomFeaturizer()
638638
self.edge_featurizer = AttentiveFPBondFeaturizer(self_loop=True)
@@ -656,7 +656,7 @@ def __getitem__(self, index):
656656
v_d = self.df.iloc[index]['drug_encoding']
657657
if self.config['drug_encoding'] == 'CNN' or self.config['drug_encoding'] == 'CNN_RNN':
658658
v_d = drug_2_embed(v_d)
659-
elif self.config['drug_encoding'] in ['DGL_GCN', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'AttentiveFP']:
659+
elif self.config['drug_encoding'] in ['DGL_GCN', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'DGL_AttentiveFP']:
660660
v_d = self.fc(smiles = v_d, node_featurizer = self.node_featurizer, edge_featurizer = self.edge_featurizer)
661661
v_p = self.df.iloc[index]['target_encoding']
662662
if self.config['target_encoding'] == 'CNN' or self.config['target_encoding'] == 'CNN_RNN':
@@ -681,7 +681,7 @@ def __init__(self, list_IDs, labels, df, **config):
681681
from functools import partial
682682
self.fc = partial(smiles_to_bigraph, add_self_loop=True)
683683

684-
elif self.config['drug_encoding'] == 'AttentiveFP':
684+
elif self.config['drug_encoding'] == 'DGL_AttentiveFP':
685685
from dgllife.utils import smiles_to_bigraph, AttentiveFPAtomFeaturizer, AttentiveFPBondFeaturizer
686686
self.node_featurizer = AttentiveFPAtomFeaturizer()
687687
self.edge_featurizer = AttentiveFPBondFeaturizer(self_loop=True)
@@ -704,12 +704,12 @@ def __getitem__(self, index):
704704
v_d = self.df.iloc[index]['drug_encoding_1']
705705
if self.config['drug_encoding'] == 'CNN' or self.config['drug_encoding'] == 'CNN_RNN':
706706
v_d = drug_2_embed(v_d)
707-
elif self.config['drug_encoding'] in ['DGL_GCN', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'AttentiveFP']:
707+
elif self.config['drug_encoding'] in ['DGL_GCN', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'DGL_AttentiveFP']:
708708
v_d = self.fc(smiles = v_d, node_featurizer = self.node_featurizer, edge_featurizer = self.edge_featurizer)
709709
v_p = self.df.iloc[index]['drug_encoding_2']
710710
if self.config['drug_encoding'] == 'CNN' or self.config['drug_encoding'] == 'CNN_RNN':
711711
v_p = drug_2_embed(v_p)
712-
elif self.config['drug_encoding'] in ['DGL_GCN', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'AttentiveFP']:
712+
elif self.config['drug_encoding'] in ['DGL_GCN', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'DGL_AttentiveFP']:
713713
v_p = self.fc(smiles = v_p, node_featurizer = self.node_featurizer, edge_featurizer = self.edge_featurizer)
714714
y = self.labels[index]
715715
return v_d, v_p, y
@@ -756,7 +756,7 @@ def __init__(self, list_IDs, labels, df, **config):
756756
from functools import partial
757757
self.fc = partial(smiles_to_bigraph, add_self_loop=True)
758758

759-
elif self.config['drug_encoding'] == 'AttentiveFP':
759+
elif self.config['drug_encoding'] == 'DGL_AttentiveFP':
760760
from dgllife.utils import smiles_to_bigraph, AttentiveFPAtomFeaturizer, AttentiveFPBondFeaturizer
761761
self.node_featurizer = AttentiveFPAtomFeaturizer()
762762
self.edge_featurizer = AttentiveFPBondFeaturizer(self_loop=True)
@@ -780,7 +780,7 @@ def __getitem__(self, index):
780780
v_d = self.df.iloc[index]['drug_encoding']
781781
if self.config['drug_encoding'] == 'CNN' or self.config['drug_encoding'] == 'CNN_RNN':
782782
v_d = drug_2_embed(v_d)
783-
elif self.config['drug_encoding'] in ['DGL_GCN', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'AttentiveFP']:
783+
elif self.config['drug_encoding'] in ['DGL_GCN', 'DGL_NeuralFP', 'DGL_GIN_AttrMasking', 'DGL_GIN_ContextPred', 'DGL_AttentiveFP']:
784784
v_d = self.fc(smiles = v_d, node_featurizer = self.node_featurizer, edge_featurizer = self.edge_featurizer)
785785
y = self.labels[index]
786786
return v_d, y
@@ -855,7 +855,7 @@ def generate_config(drug_encoding = None, target_encoding = None,
855855
gnn_activation = F.relu,
856856
neuralfp_max_degree = 10,
857857
neuralfp_predictor_hid_dim = 128,
858-
neuralfp_predictor_activation = F.tanh,
858+
neuralfp_predictor_activation = torch.tanh,
859859
attentivefp_num_timesteps = 2
860860
):
861861

@@ -938,7 +938,7 @@ def generate_config(drug_encoding = None, target_encoding = None,
938938
elif drug_encoding == 'DGL_GIN_ContextPred':
939939
## loaded pretrained model specifications
940940
pass
941-
elif drug_encoding == 'AttentiveFP':
941+
elif drug_encoding == 'DGL_AttentiveFP':
942942
base_config['gnn_hid_dim_drug'] = gnn_hid_dim_drug
943943
base_config['gnn_num_layers'] = gnn_num_layers
944944
base_config['attentivefp_num_timesteps'] = attentivefp_num_timesteps

0 commit comments

Comments
 (0)