如何解决如何在Python中正确索引元素?
我正在尝试实现以下功能来训练神经网络,如下所示:
# Here I am trying to convert train edges to nx.graph
data.edge_index = torch.from_numpy(edges(data._train)).long()
G = nx.Graph()
edge_numpy = data.edge_index.numpy()
edge_list = []
for i in range(data.num_edges):
edge_list.append(tuple(edge_numpy[:,i]))
G.add_edges_from(edge_list)
data.G = G
# These are nodes from training graph
nodes = list(G.nodes())
new = []
# These are features for the whole graph
feature = data.x.detach().cpu().numpy()
# Here the all set is calculated from all nodes in whole graph
all = get_seedsets(data.num_nodes,c=0.5)
print(all)..... [array([5,1,2]),array([1])]
for i in range(len(all)):
temp_id = all[i]
specific_features=np.zeros((feature.shape[0],feature.shape[1])
# Here I am trying to copy features of each node in the all to specific_features
for v in range(len(nodes)):
y = nodes.index(v).........*ValueError: 180 is not in list*
if y in temp_id:
specific_features[nodes[v]] = feature[y]
但是,我遇到此错误:
V`alueError:180不在列表中*
我该怎么办?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。