pyg-team / pytorch_geometric

Graph Neural Network Library for PyTorch
https://pyg.org
MIT License
21.47k stars 3.68k forks source link

Error messages appears in qm9_pretrained_schnet.py #8528

Closed xufliu closed 11 months ago

xufliu commented 11 months ago

šŸ› Describe the bug

Example code: https://github.com/pyg-team/pytorch_geometric/blob/master/examples/qm9_pretrained_schnet.py

import argparse import os.path as osp import torch from tqdm import tqdm from torch_geometric.datasets import QM9 from torch_geometric.loader import DataLoader from torch_geometric.nn import SchNet

parser = argparse.ArgumentParser() parser.add_argument('--cutoff', type=float, default=10.0, help='Cutoff distance for interatomic interactions') args = parser.parse_args()

path = osp.join(osp.dirname(osp.realpath(file)), '..', 'data', 'QM9') dataset = QM9(path)

device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') print(device)

for target in range(12): model, datasets = SchNet.from_qm9_pretrained(path, dataset, target) train_dataset, val_dataset, test_dataset = datasets

''' Traceback (most recent call last): File "C:\Program Files\Python38\lib\runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Program Files\Python38\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "c:\Users\Administrator.vscode\extensions\ms-python.python-2023.20.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher/../..\debugpy__main.py", line 39, in cli.main() File "c:\Users\Administrator.vscode\extensions\ms-python.python-2023.20.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 430, in main run() File "c:\Users\Administrator.vscode\extensions\ms-python.python-2023.20.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 284, in run_file runpy.run_path(target, run_name="main") File "c:\Users\Administrator.vscode\extensions\ms-python.python-2023.20.0\pythonFiles\lib\python\debugpy_vendored\pydevd_pydevd_bundle\pydevd_runpy.py", line 321, in run_path return _run_module_code(code, init_globals, run_name, File "c:\Users\Administrator.vscode\extensions\ms-python.python-2023.20.0\pythonFiles\lib\python\debugpy_vendored\pydevd_pydevd_bundle\pydevd_runpy.py", line 135, in _run_module_code _run_code(code, mod_globals, init_globals, File "c:\Users\Administrator.vscode\extensions\ms-python.python-2023.20.0\pythonFiles\lib\python\debugpy_vendored\pydevd_pydevd_bundle\pydevd_runpy.py", line 124, in _run_code exec(code, run_globals) File "D:\git\test\ICML2021-Gem\qm9_schnet.py", line 23, in model, datasets = SchNet.from_qm9_pretrained(path, dataset, target) File "C:\Users\Administrator\AppData\Roaming\Python\Python38\site-packages\torch_geometric\nn\models\schnet.py", line 252, in from_qm9_pretrained
net.readout = 'mean' if mean is True else 'add' File "C:\Users\Administrator\AppData\Roaming\Python\Python38\site-packages\torch\nn\modules\module.py", line 1733, in
setattr__ raise TypeError(f"cannot assign '{torch.typename(value)}' as child module '{name}' " TypeError: cannot assign 'str' as child module 'readout' (torch.nn.Module or None expected) '''

Versions

python: 3.8.10 pytorch: 2.1.0 torch-geometric: 2.4.0 torch-scatter: 2.1.2+pt21cpu torch-sparse: 0.6.18+pt21cpu schnetpack: 1.0.1

EdisonLeeeee commented 11 months ago

Thank you for the issue, will fix it via #8529