python - ValueError:行索引超出矩阵维度稀疏 coo 最大值
问题描述
我真的不知道根本原因是什么!我在下面创建了矩阵并尝试增加(M,N)大小,或减小数据大小或行大小或列大小,甚至将 dtype 从 float32 更改为 float64,但都失败了!我不断收到“行索引超出矩阵尺寸”错误,如果您有任何线索,请帮助,谢谢。
adj = sp.coo_matrix((np.ones(edges.shape[0]), (edges[:, 0],edges[:, 1])),
shape=(np.max(node_labels.shape[0])+1, np.max(node_labels.shape[0])+1), dtype=np.float32)
除了,
len(np.ones(edges.shape[0])) = len(edges[:, 0]) = len(edges[:, 1])= 1432000
和
len(node_labels.shape[0]) = 1432002
np.max(node_labels.shape[0])+1 = 1432003
您可能已经发现,我的“edges”大小比“node_labels”的大小要小得多,为什么我仍然得到行索引超出错误???
解决方案
我自己解决了这个问题,好吧,事实很残酷,只需要重新编码edges[:, 0])和edges[:, 1]中的值,但是我不知道它会如何影响我的gcn模型,因为我只对 edge.csv 的列进行编码,而使 nodes.csv 保持不变......
推荐阅读
- android - 使用 Qt 在 Android 上访问共享存储
- c++ - 在 ARM 裸机上使用 Boost.coroutine2
- azure - Azure 云 Web 应用程序在启动时会减慢加载速度
- java - Spring WebMVC 5 - 基于注解的拦截器
- google-cloud-platform - Google Cloud Pub-Sub 的 Avro 消息?
- javascript - Filtering an Observable based on a past value of another
- javascript - 带有 AJAX 的数据表,求和并添加总页脚
- powerbi - Power BI(DAX 或 Power Query)中 3 个月滚动平均值的季度总和
- android - RNCamera 文本识别在纵向模式下失败
- xml - 没有使用javascript从XML树的根元素中获取最后一个孩子