torch_geometric.nn radius_graph 示例给出 AttributeError

问题描述 投票:0回答:0

当尝试从

radius_graph
执行
torch_geometric
的示例代码时 我收到以下错误:

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 中使用带有 VScode 的 python 3.8

编辑: 我尝试在 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

(最后一部分

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

谢谢你到目前为止的帮助

pytorch torch pytorch-geometric graph-neural-network
© www.soinside.com 2019 - 2024. All rights reserved.