1

I am trying to reproduce the example from this documentation of chemicalX here. But I am receiving this error AttributeError: type object 'Molecule' has no attribute 'dummy_atom'. I have tried to look into the documentation and found out there is no dummy_atom in the Molecule class but unable to resolve this error.

from chemicalx.data import DrugCombDB, BatchGenerator
import torch
from chemicalx.models import DeepSynergy

loader = DrugCombDB()

context_set = loader.get_context_features()
drug_set = loader.get_drug_features()
triples = loader.get_labeled_triples()

train, test = triples.train_test_split(train_size=0.5)

generator = BatchGenerator(batch_size=1024,
                           context_features=True,
                           drug_features=True,
                           drug_molecules=False,
                           context_feature_set=context_set,
                           drug_feature_set=drug_set,
                           labeled_triples=train)



model = DeepSynergy(context_channels=112,
                    drug_channels=256)

optimizer = torch.optim.Adam(model.parameters())
model.train()
loss = torch.nn.BCELoss()

for batch in generator:
    optimizer.zero_grad()
    prediction = model(batch.context_features,
                       batch.drug_features_left,
                       batch.drug_features_right)
    loss_value = loss(prediction, batch.labels)
    loss_value.backward()
    optimizer.step()
harsh
  • 435
  • 2
  • 6
  • 13

1 Answers1

1

try installing an older version of torchdrug

for example:

pip install torchdrug==0.1.3.post1

explanation: this seems to caused by a recent change in the code for torchdrug.

another workaround is to modify chemicalx\constants.py the last line should be:

TORCHDRUG_NODE_FEATURES = len(atom_default(Molecule.dummy_mol.GetAtomWithIdx(0)))
Avi
  • 21
  • 4