![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
图卷积
清纯世纪
知识的搬运工
展开
-
获取 Numpy 数组中指定元素的索引位置
代码:import numpy as npa = np.array([[1,3,5],[5,8,3],[3,1,2]])b = np.where(a == 1)b1 = np.argwhere(a == 1)print(b)print(b1) 输出:emulated/0/qpython/4.py" && exit <(array([0, 2], dtype=int32), array([0, 1], dtype=int3...原创 2021-11-15 12:29:26 · 8134 阅读 · 0 评论 -
对数据进行排序、掩膜提取
代码:import numpy as npa = np.array([2,4,0])b = sorted(a) # 给 a 从小到大进行排序print("a sorted之后的值:\n",b)c = np.array([[5,6,9,8,5,6,8], [5,1,9,0,5,6,8], [5,4,8,8,4,6,2], [5,1,8,0,4,0,2], [5,4,2,7,原创 2021-11-12 13:46:38 · 592 阅读 · 0 评论 -
图卷积 中搭建边信息的代码解释
代码:import numpy as npimport itertoolsimport scipy.sparse as spedge_index=[] # 建立一个空列表dst = {2:[5,6,9,8,8],3:[9,8,8],6:[5,9,8]} # 边的信息for i, j in dst.items(): # 格式为 {index:[index_of_neighbor_nodes]} edge_index.extend([i, v] for v in j) edg原创 2021-11-12 14:07:10 · 423 阅读 · 0 评论 -
图卷积的训练代码示意(以cora数据为例)
代码:import itertoolsimport osimport os.path as ospimport pickleimport urllibfrom collections import namedtupleimport numpy as npimport scipy.sparse as spimport torchimport torch.nn as nnimport torch.nn.functional as Fimport torch.nn.init as i原创 2021-11-12 14:33:33 · 1127 阅读 · 1 评论 -
【图卷积】如何将矩阵中满足条件的位置置于1
代码:import numpy as npa = np.array([[6,3,8],[5,8,3],[3,5,2]])b = np.zeros((3,3))b[a>4] = Trueprint(b) 输出:emulated/0/qpython/4.py" && exit <[[1. 0. 1.] [1. 1. 0.] [0. 1. 0.]]#[QPython] Press enter to exit ......原创 2021-11-14 16:38:24 · 406 阅读 · 0 评论