一、Cora数据运行下面代码不能正常下载
from torch_geometric.datasets import Planetoid
folder = '"node_classify/cora"'
dataset = Planetoid(root=folder, name=data_name,
transform=T.NormalizeFeatures())
原因:
在planetoid.py源代码文件中
url = 'https://github.com/kimiyoung/planetoid/raw/master/data'
而实际的github中的数据集地址为:
url = 'https://github.com/kimiyoung/planetoid/tree/master/data'
解决办法:
将planetoid.py中第90行代码中的‘raw’改为‘tree’即可。
修改前:
@property
def raw_dir(self):
return osp.join(self.root, self.name, 'raw')
修改后:
@property
def raw_dir(self):
return osp.join(self.root, self.name, 'tree')
此时便可以使用Planetoid()函数正常下载Cora数据集。
二、在可以正常下载Cora数据集后,又出现新的问题
问题:planetoid.py中第66行代码不能正常读取下载后的文件
报错如下:
out = pickle.load(f, encoding='latin1')
UnpicklingError: invalid load key, '\x0a'.
报错原因:
planetoid.py下载的数据格式为网页,不是真实的数据。
解决办法:
(1)运行planetoid.py文件下载数据;
(2)使用git下载数据,并替换上一步下载的数据。
git clone https://gitee.com/jiajiewu/planetoid.git
or
git clone https://github.com/kimiyoung/planetoid.git
(3)在planetoid.py中暂时屏蔽掉down_load()函数。