pytorch torch_geometric.nn radius_graph示例给出AttributeError

new9mtju  于 12个月前  发布在  其他
关注(0)|答案(1)|浏览(243)

当尝试从torch_geometric执行radius_graph的示例代码时,我得到以下错误:

File "C:\Users\nico_\AppData\Local\Programs\Python\Python38\lib\site-packages\torch_geometric\nn\pool\__init__.py", line 210, in radius_graph
    return torch_cluster.radius_graph(x, r, batch, loop, max_num_neighbors,
AttributeError: 'NoneType' object has no attribute 'radius_graph'

字符串
给出错误的代码是https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.pool.radius_graph.html#torch_geometric.nn.pool.radius_graph

import torch
from torch_geometric.nn import radius_graph

x = torch.Tensor([[-1, -1], [-1, 1], [1, -1], [1, 1]])
batch = torch.tensor([0, 0, 0, 0])
edge_index = radius_graph(x, r=1.5, batch=batch, loop=False)


我也尝试导入from torch_geometric.nn.pool,但给出了相同的错误,好像它没有找到函数。
我在Windows 11中使用Python 3.8和VScode
编辑:我试着在pycharm中设置venv,只是为了这个项目,现在问题已经转移到安装torch_cluster上了(torch 1.13和2.0都有同样的问题):在安装torch_geometric 2.3.0之后,我输入命令
pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-1.13.0+cpu.html
(with最后一部分torch-xxx+cpu.html 1.13或2.0当尝试与 Torch 1.13或2.0,都没有工作)它给了我这个错误:

Looking in links: https://data.pyg.org/whl/torch-1.13.0+cpu.html
ERROR: Could not find a version that satisfies the requirement pyg_lib (from versions: none)
ERROR: No matching distribution found for pyg_lib


谢谢你的帮助

l7mqbcuq

l7mqbcuq1#

重新安装一切解决了问题,一如既往,工作依赖是torch -> 2.0.0+cpu,torch_gemetric -> 2.3.0,torch_cluster -> 1.6.1+ pt 20 cpu,python -> 3.8

相关问题