torchdrug
torchdrug copied to clipboard
Help needed using a molecular dataset
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?
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.
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'
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.
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)
That fixes it for me, thanks!
nice!