torchdrug
torchdrug copied to clipboard
Can't kekulize mol.
When I ran the code below(same as the demo in retrosynthesis tutorial)
from torchdrug import data, datasets, utils
from torchdrug.utils import plot
from torchdrug import core, models, tasks
synthon_dataset = datasets.USPTO50k("~/data", as_synthon=True,
node_feature="synthon_completion",
kekulize=True)
torch.manual_seed(1)
synthon_train, synthon_valid, synthon_test = synthon_dataset.split()
synthon_model = models.RGCN(input_dim=synthon_dataset.node_feature_dim,
hidden_dims=[256, 256, 256, 256, 256, 256],
num_relation=synthon_dataset.num_bond_type,
concat_hidden=True)
synthon_task = tasks.SynthonCompletion(synthon_model, feature=("graph",))
synthon_optimizer = torch.optim.Adam(synthon_task.parameters(), lr=1e-3)
synthon_solver = core.Engine(synthon_task, synthon_train, synthon_valid,
synthon_test, synthon_optimizer,
gpus=[0], batch_size=128)
synthon_solver.train(num_epoch=10)
synthon_solver.evaluate("valid")
synthon_solver.save("~/data/g2gs_synthon_model.pth")
an exception appeared:
Chem.Kekulize(mol)
rdkit.Chem.rdchem.KekulizeException: Can't kekulize mol. Unkekulized atoms: 11
Have anyone encountered that case, and how did you solve? Vary appreciated for relpies!
I met the same question
Sorry for the inconvience. I've changed rdkit version to 2021.9.2, which can address the problem in my case. Maybe you can have a try.
If it doesn't work for you, could you please tell us your pytorch and rdkit version? Since I'm not a developer for the retrosynthesis part, maybe @KiddoZhu and @shichence will help you on this.
Sorry for the inconvience. I've changed rdkit version to 2021.9.2, which can address the problem in my case. Maybe you can have a try.
If it doesn't work for you, could you please tell us your pytorch and rdkit version? Since I'm not a developer for the retrosynthesis part, maybe @KiddoZhu and @shichence will help you on this.
Thx! The problem is solved with the rdkit version you offered, the version I previously used is 2022.9.3 .
For anyone working on OSX (M1), I was able to succeed using version 2021.9.4.
pip install rdkit-pypi-2021.9.4