torchdrug icon indicating copy to clipboard operation
torchdrug copied to clipboard

Help needed using a molecular dataset

Open bananenpampe opened this issue 2 years ago • 6 comments

Hello together,

I have created a molecular dataset using:

dataset_train.load_smiles(Strain,targets={"property":Ytrain_full})

Now, when I want to create an Engine from a defined task:

task = tasks.PropertyPrediction(model, task=dataset_train.tasks,
criterion="bce", metric=("auprc", "auroc"),num_class=3)
optimizer = torch.optim.Adam(task.parameters(), lr=1e-3)
solver = core.Engine(task, train_set, valid_set, test_set, optimizer, batch_size=1024)

I receive the following error:

'MoleculeDataset' object has no attribute 'config_dict'

How can I set the config dict using a user defined dataset?

bananenpampe avatar Oct 06 '22 15:10 bananenpampe

Hi!

Every class inherited from core.Configurable should has an attribute 'config_dict', e.g., data.MoleculeDataset. Could you show the code of our defined dataset? It will help us find the reason of the error.

Oxer11 avatar Oct 12 '22 00:10 Oxer11

Got the same issue with MoleculeDataset

mol_dataset = torchdrug_data.dataset.MoleculeDataset()

mol_dataset.load_csv('data_dippr_liquid_heat_capacity_smiles.csv', smiles_field='SMILES')
model = models.RGCN(input_dim=mol_dataset.node_feature_dim,
                    num_relation=mol_dataset.num_bond_type,
                    hidden_dims=[10, 10, 10, 10])

task = tasks.GCPNGeneration(model, mol_dataset.atom_types, max_edge_unroll=12, max_node=38, criterion='nll')

optimizer = optim.Adam(task.parameters(), lr = 1e-3)

solver = core.Engine(task, mol_dataset, None, None, optimizer)
AttributeError: 'MoleculeDataset' object has no attribute 'config_dict'

taidbui avatar Oct 17 '22 10:10 taidbui

Has there been progress on this or a fix using a different class? I have the same issue as the others and want to know what I can do to circumvent this issue while using custom molecule datasets.

BobvanSchendel avatar Oct 31 '22 14:10 BobvanSchendel

Hello,

for me this fix worked, I assume ther is something wrong eith this wrapper:


from torchdrug.core import Registry as R


@R.register("datasets.Solvation")
class mymoldataset(data.MoleculeDataset):
    def __init__(self,*args,**kwargs):
        super().__init__(*args,**kwargs)

bananenpampe avatar Oct 31 '22 16:10 bananenpampe

That fixes it for me, thanks!

BobvanSchendel avatar Oct 31 '22 16:10 BobvanSchendel

nice!

bananenpampe avatar Oct 31 '22 16:10 bananenpampe