图神经网络
文章平均质量分 69
近年来,由于图神经网络的强大表现力,用机器学习方法分析图的研究越来越受到重视。图神经网络(GNN)是一类基于深度学习的处理图域信息的方法。由于其较好的性能和可解释性,GNN最近已成为一种广泛应用的图分析方法。
海洋 之心
阿里云社区专家博主,图神经网络-大数据-推荐系统研究者,专注于计算机领域前沿技术的分享等人工智能算法研究工作
展开
-
PyTorch+PyG实现图神经网络经典模型目录
本专栏整理了《图神经网络代码实战》,内包含了不同图神经网络的相关代码实现(PyG以及自实现),理论与实践相结合,如GCN、GAT、GraphSAGE等经典图网络,每一个代码实例都附带有完整的代码。原创 2023-01-19 21:50:32 · 28758 阅读 · 298 评论 -
ImportError: cannot import name ‘from_dict‘ from ‘torch_geometric.data‘ (/Users/liam/opt/anaconda3/l
包下没有这个函数,所以会出现导入失败,无法找到该函数的错误。库来自定义图数据,使用函数。这样即可将自定义的字典转化为。的图格式,出现如下问题。原创 2024-07-24 15:55:29 · 40 阅读 · 0 评论 -
AttributeError: ‘pandas._libs-properties-CachedProperty‘ object has no attribute ‘func‘
【代码】AttributeError:'pandas._libs-properties-CachedProperty'objecthasnoattribute'func'原创 2024-06-01 21:00:23 · 210 阅读 · 0 评论 -
ValueError:x andy must have same first dimension, but have shapes (15,) and (17,)
进行数据分析建模出现如下问题。出现这个问题的原因是。原创 2024-06-01 20:57:17 · 501 阅读 · 0 评论 -
完美解决ImportError: cannot import name ‘HANConv‘ from ‘torch_geometric.nn‘ (/Library/Frameworks/Python.
这个卷积层,所以会出现无法导入的问题。异构图神经网络的代码,当导入。出现这个问题的原因就是当前的。这个卷积层出现如下问题。原创 2024-02-21 08:55:47 · 190 阅读 · 0 评论 -
完美解决torch-geometric WinDLL(os.path.abspath(filename)) OSError: [WinError 126] 找不到指定的模块
这个问题不一定是由这个导致的,一定要看我上面图标记的红框,看你的是不是这个原因,如果不是那么下main的解决办法可能无用,因为。的版本,所以更换他很可能导致用不了。出现了问题,出现这个问题的原因是。这个库来搭建图卷积模块时出现。的版本依赖原因,当前版本的。但是个人不建议这种方式,因为。的版本,可以选择把旧版本的。需要依赖很多其他的库以及。建议使用这种方式,仅仅更新。对于我的问题出现的原因是。可以由很多问题导致。原创 2024-02-21 08:43:46 · 287 阅读 · 0 评论 -
完美解决ModuleNotFoundError: No module named ‘torch_sparse‘
但仍无法正常运行,因为该库还依赖其他一些库。为了解决这个问题,我们需要安装所有的依赖库,包括。这样是不行的,因为需要特定版本之间的依赖关系,有的版本之间不兼容。库在实现图神经网络方面的东西,在运行期间出现如下问题。但是还需注意一点,这个库依赖关系比较严格,仅仅用。大家可以按照我的环境进行安装。出现这个问题的原因是缺少。原创 2024-02-21 08:12:34 · 1294 阅读 · 1 评论 -
TypeError: Failed to convert object of type <class ‘tensorflow.python.data.ops.dataset_ops._NestedV
最后,确保模型的输入层能够接受这种新的数据结构,包括名称和形状的匹配。检查模型的输入层定义,确保它们与数据集结构一致。但在某些情况下,输入数据已经是 TensorFlow 数据集,而不是直接的张量。确保输入数据是张量而不是 TensorFlow 数据集。如果输入数据已经是数据集,需要进行相应的处理。如果输入数据是 TensorFlow 数据集,你需要将它们合并为一个数据集,然后通过。两个输入层已经是 TensorFlow 数据集而不是张量。转换为模型所需的结构,最后通过。是输入数据的数据集,通过。原创 2024-02-20 08:34:44 · 118 阅读 · 0 评论 -
RuntimeError: Providing a bool or integral fill value without setting the optional dtype or out argu
参数的情况下,提供布尔值或整数值的填充值是不支持的,我使用的版本是。上的一段代码出现如下问题。原创 2024-02-20 08:13:01 · 169 阅读 · 0 评论 -
Cannot find reference ‘attention‘ in ‘__init__.py‘
更新到最新或者更新到 2.4.0+以上即可。这条指令时突然找不到这个模块,出现。的版本太低了,目前还没有引入这个模块。出现这个问题的原因就是你的。原创 2024-01-08 15:20:49 · 359 阅读 · 0 评论 -
error while use ‘‘ pip install torch-geometric ‘‘ ,ERROR: Failed building wheel for llvmlite
如果您安装的PyTorch版本低于1.9.*,可能会遇到兼容性问题。旧版本的PyTorch可能无法完全支持最新的。在Anaconda的虚拟环境中使用指令。原创 2024-01-08 13:36:41 · 422 阅读 · 0 评论 -
TypeError: full() received an invalid combination of arguments - got (tuple, int, device=NoneType),
等参数都应该是 PyTorch 的张量(tensor)对象,而不是 Python 列表或 NumPy 数组。内置的DataLoader构造迭代器时出现如下问题。所有对象都创建成了Python中的列表。原创 2023-10-17 14:42:26 · 513 阅读 · 0 评论 -
The size of tensor a (20) must match the size of tensor b (10) at non-singleton dimension 2 GCN trai
使用PyG搭建一个链路预测的GCNs模型出现了如下问题 `RuntimeError: The size of tensor a (20) must match the size of tensor b (10) at non- singleton dimension 2`原创 2023-09-17 08:55:20 · 331 阅读 · 0 评论 -
OSError: dlopen(/Users/psanchez/miniconda3/envs/playbook/lib/python3.9/site-packages/libpyg.so, 0x00
安装好 `torch-geometric` 之后,使用 `import torch_geometric` 时出现如下问题 `OSError: dlopen(/Users/psanchez/miniconda3/envs/playbook/lib/python3.9/site-packages/libpyg.so, 0x0006): Library not loaded: /usr/local/opt/python@3.10/Frameworks/Python.framework/Versions/3.10原创 2023-09-16 15:03:57 · 754 阅读 · 0 评论 -
成功解决AttributeError: ‘tuple‘ object has no attribute ‘x‘
从 `Github` 上下载了一个图神经网络的边缘预测项目,使用GCN运行预测时出现如下问题 `AttributeError: 'tuple' object has no attribute 'x'`原创 2023-09-16 14:50:37 · 1478 阅读 · 0 评论 -
RuntimeError: CUDA error: invalid device ordinal CUDA kernel errors might be asynchronously reported
在运行代码 `args.device = torch.device('cuda: ' + str(args.gpu_id))` 设置GPU时出现如下问题 `RuntimeError: CUDA error: invalid device ordinal CUDA kernel errors might be asynchronously reported`原创 2023-08-31 07:35:35 · 1107 阅读 · 0 评论 -
解决ValueError: n_splits=10 cannot be greater than the number of members in each class.
在训练模型时使用到了交叉验证,当我设置 `n_split = 10` 出现如下问题 `ValueError: n_splits=10 cannot be greater than the number of members in each class.`原创 2023-08-28 10:36:44 · 785 阅读 · 0 评论 -
成功解决BrokenPipeError: [Errno 32] Broken pipe
我出现这个问题是由于多线程加载数据导致,在某些操作系统或环境中(尤其是Windows),多进程支持可能没有很好地实现,这也可能导致问题。使用PyTorch创建一个DataLoader迭代器,进行模型训练时出现如下问题。,利用4个线程去加载数据,这种策略目前是在。原创 2023-08-24 16:17:47 · 1174 阅读 · 1 评论 -
TypeError: GCNConv.forward() missing 1 required positional argument: ‘edge_index‘
使用 `GCN` 网络进行图节点分类任务,然后出现如下问题 `TypeError: GCNConv.forward() missing 1 required positional argument: 'edge_index'`原创 2023-08-10 09:44:19 · 423 阅读 · 0 评论 -
OSError: libc10_hip.so: cannot open shared object file: No such file or directory
安装了 `torch` 和 `torch-geometric` ,然后想运行Github上的一个示例图神经网络的代码,出现了如下问题 `OSError: libc10_hip.so: cannot open shared object file: No such file or directory`原创 2023-08-10 09:32:37 · 493 阅读 · 0 评论 -
RuntimeError: object has no attribute sparse_csc_tensor: File “/home/lbilic/anaconda3/envs/diffdock/
使用 `torch-geometric` 运行一个图神经网络Demo,出现了如下问题 `RuntimeError:object has no attribute sparse_csc_tensor:File "/home/lbilic/anaconda3/envs/diffdock/lib/python3.9/site-packages/torch_sparse/tensor.py", line 520value = torch.ones(self.nnz(), dtype=dtype, device原创 2023-08-09 20:53:04 · 759 阅读 · 0 评论 -
ModuleNotFoundError: No module named ‘torch_geometric.loader
我在学习 `torch-geometric` 这个库,使用 `from torch_geometric.loader import DataLoader` ,然后出现如下问题 `ModuleNotFoundError: No module named 'torch_geometric.loader`原创 2023-08-09 20:44:22 · 1184 阅读 · 0 评论 -
ImportError: ‘SparseTensor‘ requires ‘torch-sparse‘
安装好 `torch-geometric` 、 `torch` 和 `torch-sparse` 之后,运行从 `Github` 拷贝下来的图神经网络项目出现如下问题 `ImportError: 'SparseTensor' requires 'torch-sparse'`原创 2023-08-09 20:33:34 · 781 阅读 · 0 评论 -
AttributeError: module ‘torch‘ has no attribute ‘sparse_csc‘
在训练图神经网络时,我遭遇了一个问题,即 AttributeError: module 'torch' has no attribute 'sparse_csc'。我使用的是 PyTorch 和 torch-geometric 库。经过排查,我发现这个问题的根源出在库的版本兼容性上。原创 2023-08-09 10:28:30 · 730 阅读 · 0 评论 -
图神经网络 RuntimeError: expected scalar type Double but found Float
使用 `GCN` 实现图分类任务,然后数据集是我自定义的,有节点特征,然后搭建模型运行出现了如下问题 `RuntimeError: expected scalar type Double but found Float`原创 2023-08-05 10:31:10 · 92 阅读 · 0 评论 -
ModuleNotFoundError: No module named ‘torch_scatter‘
粉丝交流群一位初学 `torch-geometric` 这个工具包的伙伴在使用 `from torch_geometric.data import Data` 出现如下问题 `ModuleNotFoundError: No module named 'torch_scatter'`原创 2023-08-05 10:17:08 · 1405 阅读 · 0 评论 -
OSError: dlopen(/usr/local/Caskroom/miniconda/base/envs/my_conda_env/lib/python3.8/site-packages/tor
一位订阅了专栏的粉丝私信我他的一个问题,他在导入 `torch_sparse` 出现了如下问题 `OSError: dlopen(/usr/local/Caskroom/miniconda/base/envs/my_conda_env/lib/python3.8/site-packages/torch_sparse/_version.so, 6): Symbol not found: __ZN3c105ErrorC1ENS_14SourceLocationERKNSt3__112basic_stringIc原创 2023-08-05 10:06:09 · 330 阅读 · 0 评论 -
OSError: /anaconda3/lib/python3.7/site-packages/torch_sparse/_version_cuda.so: undefined symbol: _ZN
在使用 `torch-geometric` 这个库编写图分类代码,在运行时出现如下问题 `OSError Traceback (most recent call last)...OSError: /anaconda3/lib/python3.7/site-packages/torch_sparse/_version_cuda.so: undefined symbol: _ZN5torch3jit17parseSchemaOrNameER原创 2023-08-05 09:50:11 · 1865 阅读 · 0 评论 -
error: Microsoft Visual C++ 14.0 is required. Get it with “Build Tools for Visual Studio“: https://v
在安装 `torch_geometric` 、 `torch-sparse` 和 `torch-scatter` 时使用 `pip install ***` 在cmd中出现如下问题 `ERROR: Command errored out with exit status 1: command: 'C:\Users\hastings\anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\User原创 2023-08-05 09:27:04 · 451 阅读 · 0 评论 -
No matching distribution found for torch-geometri satisfies the requirement torch-geometric
初期学习图神经网络时需要用到 `torch-geometric` 这个工具包,想要安装它,不过出现了如下问题 `ERROR: No matching distribution found for torch-geometri satisfies the requirement torch-geometric`原创 2023-08-05 09:14:36 · 712 阅读 · 0 评论 -
ERROR: Could not find a version that satisfies the requirement torch-sparse ERROR: No matching distr
在使用 `!pip install --no-index torch-sparse -f https://pytorch-geometric.com/whl/torch-1.7.0+cu102.html` 安装 `torch-sparse` 时出现如下问题 `ERROR: Could not find a version that satisfies the requirement torch-sparseERROR: No matching distribution found for torch-sp原创 2023-08-05 08:54:17 · 343 阅读 · 0 评论 -
RuntimeError: The size of tensor a (20) must match the size of tensor b (10) at non- singleton dime
使用 `PyG` 搭建 `GCN` 实现链路预测任务时,出现了如下问题 `RuntimeError: The size of tensor a (20) must match the size of tensor b (10) at non- singleton dimension 2`原创 2023-08-04 14:41:24 · 3007 阅读 · 0 评论 -
RuntimeError: Detected that PyTorch and torch_sparse were compiled with different CUDA versions.PyTo
最近一粉丝在学习图神经网络,出现如下问题:`RuntimeError: Detected that PyTorch and torch_sparse were compiled with different CUDA versions.PyTorch has CUDA version 11.3 and torch_sparse has CUDA version 11.0.Please reinstall the torch_sparse that matches your PyTorch install原创 2023-08-04 13:59:13 · 393 阅读 · 0 评论 -
FileNotFoundError: Could not find module ‘...\.conda\envs\urop\Lib\site-packages\torch_sparse\_conv
使用 `torch_geometric` 编写图神经网络代码时出现如下问题 `FileNotFoundError: Could not find module '...\.conda\envs\urop\Lib\site-packages\torch_sparse\_convert_cuda.pyd' Try using the full path with constructor syntax.`原创 2023-08-04 13:19:30 · 1437 阅读 · 0 评论 -
成功解决RuntimeError: one of the variables needed for gradient computation has been modified by an inpla
使用 `PyTorch` 训练网络出现 `RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [3008, 128]], which is output 0 of AsStridedBackward0, is at version 4; expected version 3 instead. H原创 2023-05-15 10:10:14 · 1204 阅读 · 0 评论 -
成功解决AttributeError: module ‘torch‘ has no attribute ‘sparse_csc‘
我在使用 `PyTorch` 和 `torch-geometric` 在训练图神经网络的时候出现了 `AttributeError: module 'torch' has no attribute 'sparse_csc'` 这个问题。原创 2023-05-12 20:14:06 · 5392 阅读 · 9 评论 -
AttributeError: module ‘thread‘ has no attribute ‘start_new_thread‘
使用 `PyCharm` 进行 `debug` 调试程序时出现如下问题 `AttributeError: module 'thread' has no attribute 'start_new_thread'`原创 2023-04-20 11:44:14 · 791 阅读 · 0 评论 -
Multi-task Learning(多任务学习)和Curriculum Learning(课程学习)
`Multi-task Learning`(多任务学习)和 `Curriculum Learning`(课程学习)是机器学习中两种常见的训练技巧,它们分别用于优化模型的训练过程和提高模型的泛化能力。原创 2023-04-12 08:29:57 · 299 阅读 · 0 评论 -
推荐系统中的元路径(meta-path)
推荐系统中的元路径(meta-path)是指用于描述不同类型节点之间关系的路径。在推荐系统中,元路径可以用来挖掘节点之间的相似性和影响力,从而提高推荐的准确性和多样性。原创 2023-04-12 08:01:47 · 1504 阅读 · 0 评论 -
推荐系统中召回率Recall计算方式附代码
Recall(召回率)是指在所有实际有交互的用户 - 物品对中,推荐系统成功预测出的比例。具体来说,设所有有交互的用户 - 物品对为S,推荐系统预测出的用户 - 物品对为T,则Recall的计算公式为:原创 2023-04-09 19:55:27 · 1079 阅读 · 0 评论