FighterLYL / GraphNeuralNetwork

《深入浅出图神经网络:GNN原理解析》配套代码
1.7k stars 457 forks source link

第7章的代码运行时报如下错误,请问怎么解决? #15

Closed gitqinxinyu closed 4 years ago

gitqinxinyu commented 4 years ago

Traceback (most recent call last): File "D:/GraphNeuralNetwork-master/GraphNeuralNetwork-master/chapter7/main.py", line 71, in train() File "D:/GraphNeuralNetwork-master/GraphNeuralNetwork-master/chapter7/main.py", line 47, in train batch_sampling_result = multihop_sampling(batch_src_index, NUM_NEIGHBORS_LIST, data.adjacency_dict) File "D:\GraphNeuralNetwork-master\GraphNeuralNetwork-master\chapter7\sampling.py", line 37, in multihop_sampling hopk_result = sampling(sampling_result[0], hopk_num, neighbor_table) File "D:\GraphNeuralNetwork-master\GraphNeuralNetwork-master\chapter7\sampling.py", line 19, in sampling res = np.random.choice(neighbor_table[sid], size=(sample_num, )) TypeError: 'coo_matrix' object does not support indexing

hunauchenym commented 4 years ago

老兄到底如何解决的呢?

hunauchenym commented 4 years ago

line 19改为: neighbor_nodes=neighbor_table.getrow(sid).nonzero() res = np.random.choice(np.array(neighbor_nodes).flatten(), size=sample_num)