当前位置:网站首页>import torch_ Data view of geometric
import torch_ Data view of geometric
2022-06-12 13:05:00 【Dongxuan】
Welcome to the column torch_geometric

Data Handling of Graphs
A processing library torch_geometric. I also found this class when watching others share code , It is out of place with the usual class .
torch_geometric.data.Data, It can simply represent a graph data . It contains the following properties
data.x: Node characteristics [ Number of nodes , Node feature dimension ][num_nodes, num_node_features]data.edge_index: It has to be this shape[2, num_edges]and typetorch.long. Must be serial number . First of all, yours. data.x It determines the order of each node index . Then specify the edges according to this sequence number , The first row of the edge is the source node , The second node is the target node .data.edge_attr: Feature representation of edges[num_edges, num_edge_features]data.y: A label for graph data , It can be a node classification task[num_nodes, *], It can also be a graph classification task[1, *]data.pos: The coordinates of point , For example, the point is in the three-dimensional coordinate system ,num_dimensions Namely 3[num_nodes, num_dimensions]
We can expand Data List of properties , For example data.face To express 3d In the clouds face The concept of . Use the sequence number of points to specify which three points form a face . [3, num_faces] and type torch.long.
A bunch of runnable examples
Example ①
import torch
from torch_geometric.data import Data
edge_index = torch.tensor([[0, 1, 1, 2],
[1, 0, 2, 1]], dtype=torch.long)
x = torch.tensor([[-1], [0], [1]], dtype=torch.float)
data = Data(x=x, edge_index=edge_index)
>>> Data(edge_index=[2, 4], x=[3, 1])perhaps edge_index The second way to write
Example ②
import torch
from torch_geometric.data import Data
edge_index = torch.tensor([[0, 1],
[1, 0],
[1, 2],
[2, 1]], dtype=torch.long)
x = torch.tensor([[-1], [0], [1]], dtype=torch.float)
data = Data(x=x, edge_index=edge_index.t().contiguous())
>>> Data(edge_index=[2, 4], x=[3, 1])Let's output the built graph data information .
print(data.keys)
>>> ['x', 'edge_index']
print(data['x'])
>>> tensor([[-1.0],
[0.0],
[1.0]])
for key, item in data:
print(f'{key} found in data')
>>> x found in data
>>> edge_index found in data
'edge_attr' in data
>>> False
data.num_nodes
>>> 3
data.num_edges
>>> 4
data.num_node_features
>>> 1
data.has_isolated_nodes()
>>> False
data.has_self_loops()
>>> False
data.is_directed()
>>> False
# Transfer data object to GPU.
device = torch.device('cuda')
data = data.to(device)边栏推荐
- [EDA] chip layout design: VLSI layout design using electric
- MUI登录数据库完善与AJAX异步处理【MUI+Flask+MongoDB+HBuilderX】
- Hardware composition of embedded system - introduction of embedded development board based on ARM
- Experience and learning path of introductory deep learning and machine learning
- 5V升压到12.6V的锂电池充电IC芯片方案FS4062B
- Array -- fancy traversal technique of two-dimensional array
- 成功跳槽阿里,进阶学习
- [database] Navicat -- Oracle database creation
- 442 authors, 100 pages! It took Google 2 years to release the new benchmark big bench | open source
- 镜像扫描工具预研
猜你喜欢

Vant tab bar + pull-up loading + pull-down refresh demo van tabs + van pull refresh + van list demo

创新实训(十一)开发过程中的一些bug汇总

Source of routing information

Part of the fourth Zhejiang CTF finals
![[you code, I fix] whitesource was officially renamed mend](/img/0f/75ac1d0b08244ed689733d38551a61.jpg)
[you code, I fix] whitesource was officially renamed mend

深度学习的多个 loss 是如何平衡的?

itk itk::BSplineDeformableTransform

Help you with everything from the basics to the source code. Introduce the technology in detail

八大误区,逐个击破(2):性能差?应用程序少?你对云的这些担心很多余!
![[embedded] serial communication and its case](/img/5c/2e691e5ef03c7d65fd514e8b940e7b.jpg)
[embedded] serial communication and its case
随机推荐
torch_geometric mini batch 的那些事
分享PDF高清版,系列篇
import torch_geometric 加载一些常见数据集
成功定级腾讯T3-2,万字解析
When to use binary search
Getting to know blob objects
Theoretical knowledge of improved DH parameters and standard DH parameters of manipulator
嵌入式系统硬件构成-嵌入式系统硬件体系结构
itk neighbhood
import torch_geometric 的Data 查看
hudi 键的生成(Key Generation)
leetcode 47. Permutations II full permutations II (medium)
Openstack network
442 authors, 100 pages! It took Google 2 years to release the new benchmark big bench | open source
Newoj week 10 question solution
Array -- seven array topics with double pointer technique
ITK Examples/RegistrationITKv4/DeformableRegistration
torch_geometric message passing network
ITK multiresolution image itk:: recursivemultiresolutionpyramidimagefilter
【刷题篇】抽牌获胜的概率