bug: No such file or directory: ‘data/ind.cora.x‘

在尝试访问'data/ind.cora.x'时遇到'No such file or directory'错误。尝试修改graphsgcn的cora路径,将data文件夹移到根目录,以及调整data_loader.py中的代码,最终通过将data文件夹拷贝到root目录解决了问题。现在能够正确读取和写入cora数据集文件。
摘要由CSDN通过智能技术生成

No such file or directory: ‘data/ind.cora.x’

把graphsgcn的cora改成data不行,把data里改成cora也不行

实际上,最后把data文件夹拷到root目录里才成功。

open文件夹data的方法,不用要.和/。

names = ['x', 'y', 'tx', 'ty', 'allx', 'ally', 'graph']
    objects = []
    for i in range(len(names)):
        with open("data/ind.{}.{}".format(dataset_str, names[i]), 'rb') as f:
            if sys.version_info > (3, 0):
                data = pkl.load(f, encoding='latin1')
                if(names[i].find('graph')==-1):
                    print(f)
                    print(data.shape)
                    for j in range(data.shape[0]): 
                        print('********',names[i],j,data[j].shape,'**********')
                        print(data[j])
                    else:
                        print(f)
                        print(data)
                objects.append(data)
                

            else:
                objects.append(pkl.load(f))

    x, y, tx, ty, allx, ally, graph = tuple(objects)

data_loader.py所有的代码

import numpy as np
import pickle as pkl
import networkx as nx
import scipy.sparse as sp
from scipy.sparse.linalg.eigen.arpack import eigsh
import sys


def parse_index_file(filename):
    """Parse index file."""
    index = []
    for line in open(filename):
        index.append(int(line.strip()))
    return index


def sample_mask(idx, l):
    """Create mask."""
    mask = np.zeros(l)
    mask[idx] = 1
    return np.array(mask, dtype=np.bool)


def load_data(dataset_str):
    """
    Loads input data from gcn/data directory

    ind.dataset_str.x => the feature vectors of the training instances as scipy.sparse.cs
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值