chao1224 / MoleculeSTM

Multi-modal Molecule Structure-text Model for Text-based Editing and Retrieval, Nat Mach Intell 2023 (https://www.nature.com/articles/s42256-023-00759-6)
https://chao1224.github.io/MoleculeSTM
Other
187 stars 18 forks source link

demos #26

Open xiaorandu opened 2 months ago

xiaorandu commented 2 months ago

Following up on my previous post, I tried to run all the demos, however, for each of them I failed at its last step, and received the pretty much the similar error. ` TypeError Traceback (most recent call last) in <cell line: 9>() 8 9 for epoch in range(1, args.epochs + 1): ---> 10 loss_acc = train_func(model, device, train_loader, optimizer) 11 print("Epoch: {}\nLoss: {}".format(epoch, loss_acc)) 12

5 frames /usr/local/lib/python3.10/dist-packages/torch/_utils.py in reraise(self) 720 # instantiate since we don't know how to 721 raise RuntimeError(msg) from None --> 722 raise exception 723 724

TypeError: Caught TypeError in DataLoader worker process 0. Original Traceback (most recent call last): File "/usr/local/lib/python3.10/dist-packages/torch/utils/data/_utils/worker.py", line 308, in _worker_loop data = fetcher.fetch(index) File "/usr/local/lib/python3.10/dist-packages/torch/utils/data/_utils/fetch.py", line 51, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/usr/local/lib/python3.10/dist-packages/torch/utils/data/_utils/fetch.py", line 51, in data = [self.dataset[idx] for idx in possibly_batched_index] File "/usr/local/lib/python3.10/dist-packages/torch_geometric/data/dataset.py", line 289, in getitem data = self.get(self.indices()[idx]) File "/content/drive/MyDrive/MoleculeSTM/MoleculeSTM/datasets/MoleculeNet_Graph.py", line 184, in get for key in self.data.keys: TypeError: 'method' object is not iterable ` Could you provide some insights on how to address this issue? Thank you!

xiaorandu commented 2 months ago

btw, I run the demo code in google colab (Python 3.10), and here are the installed packages, not sure if it is the compatible issue. ` !pip install rdkit !pip install torch torchvision !pip install requests tqdm matplotlib spacy Levenshtein boto3 deepspeed !pip install ogb==1.2.0 !pip install transformers==4.30.2

!pip install torch_geometric !pip install torch-scatter -f https://data.pyg.org/whl/torch-2.2.1+cu121.html !pip install torch-sparse -f https://data.pyg.org/whl/torch-2.2.1+cu121.html !pip install torch-cluster -f https://data.pyg.org/whl/torch-2.2.1+cu121.html !pip install torch-spline-conv -f https://data.pyg.org/whl/torch-2.2.1+cu121.html !pip install git+https://github.com/MolecularAI/pysmilesutils.git

!git clone https://github.com/chao1224/apex.git %cd apex !pip install -v --disable-pip-version-check --no-cache-dir ./ %cd .. `

MohdOwais22 commented 2 days ago

you just need to add parenthesis in /MoleculeSTM/MoleculeSTM/datasets/MoleculeNet_Graph.py", line 184 for key in self.data.keys(): and it will work fine