You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用StellarGraph加载Cora数据集时Colab出现HTTP 403错误如何解决

问题原因

出现HTTP Error 403: Forbidden错误的核心原因是Stellargraph库已停止官方维护,其默认托管Cora数据集的远程服务器地址已失效或新增了访问限制,原有代码中自动下载数据集的请求被目标服务器直接拒绝。部分场景下也可能是Colab的公共请求IP被目标服务器的防盗链规则拦截导致。

解决方案

可以任选以下任意一种方式解决:

  • 方案1:手动加载本地Cora数据集
    提前下载Cora数据集的核心文件cora.cites和cora.content上传到Colab工作目录,替换原有加载代码为:
    import pandas as pd
    import stellargraph as sg
    from stellargraph import StellarGraph
    
    # 加载边数据
    cites = pd.read_csv(
        "cora.cites",
        sep="\t",
        header=None,
        names=["target", "source"],
    )
    # 加载节点特征与标签
    content = pd.read_csv(
        "cora.content",
        sep="\t",
        header=None,
    )
    # 提取节点ID、特征、标签
    node_ids = content.iloc[:, 0]
    node_features = content.iloc[:, 1:-1].set_index(node_ids)
    node_subjects = content.iloc[:, -1].set_index(node_ids)
    # 构建StellarGraph对象
    G = StellarGraph(node_features, edges=cites)
    
  • 方案2:修改请求头模拟浏览器访问
    临时修改Stellargraph内部的数据集下载逻辑,给HTTP请求添加标准浏览器的User-Agent头,绕过基础的防盗链限制,修改后再执行原有数据集加载代码即可。
  • 方案3:从其他图学习库中转数据集
    先通过PyTorch Geometric、DGL等仍在维护的图学习库下载Cora数据集,再将数据格式转换为Stellargraph支持的图结构即可正常使用。

内容的提问来源于stack exchange,提问作者muhammad

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.07 01:36:00