GCN BASED ON pytorch geometric

导入需要用到的库和模块

`import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import torch
import torch.nn.functional as F
from torch_geometric.nn import GCNConv
from torch_geometric.datasets import Planetoid
from torch_geometric.utils import to_networkx
import networkx as nx
from sklearn.metrics import accuracy_score
from sklearn.manifold import TSNE #对数据特征进行降维
from sklearn.svm import SVC
from sklearn.semi_supervised import label_propagation

数据下载

dataset=Planetoid(root='G:/GCN_pytorch/Cora',name='Cora')
print('classes num :',dataset.num_classes)
print('edge feature num:',dataset.num_edge_features)
print('edge nums:',dataset.data.edge_index.shape[1]/2)
print('node feature nums:',dataset.num_node_features)
print('node nums:',dataset.data.x.shape[0])

data属性

print(dataset.data)

`

原文地址:https://www.cnblogs.com/Ann21/p/14865982.html