1、在edge_index上执行分割,这样训练和验证分割不包括来自验证和测试分割的边(即只有来自训练分割的边),而测试分割不包括来自测试分割的边。这是因为编码器使用edge_index和x来创建节点嵌入,这种方式确保了在对验证/测试数据进行预测时,节点嵌入上没有目标泄漏。2、向每个分割数据添加两个新属性(edge_label和edge...
edge_index=train_data.edge_index, num_nodes=train_data.num_nodes, num_neg_samples=train_data.edge_label_index.size(1), method='sparse') edge_label_index = torch.cat( [train_data.edge_label_index, neg_edge_index], dim=-1, ) edge_label = torch.cat([ train_data.edge_label, train_...
edge_index=train_data.edge_index, num_nodes=train_data.num_nodes, num_neg_samples=train_data.edge_label_index.size(1), method='sparse') edge_label_index = torch.cat( [train_data.edge_label_index, neg_edge_index], dim=-1, ) edge_label = torch.cat([ train_data.edge_label, train_...
return_type='raw', )# Explain model output for a single edge: edge_label_index = val_data.edge_label_index[:, 0]explainer = Explainer( model=model, explanation_type='model', algorithm=GNNExplainer(epochs=200), node_mask_type='attributes', edge_mask_type='object', model_config=model_co...
model_config=ModelConfig(mode='binary_classification',task_level='edge',return_type='raw',) 代码语言:javascript 复制 # Explain model outputfora single edge:edge_label_index=val_data.edge_label_index[:,0]explainer=Explainer(model=model,explanation_type='model',algorithm=GNNExplainer(epochs=200),...
edge_index=train_data.edge_index, num_nodes=train_data.num_nodes, num_neg_samples=train_data.edge_label_index.size(1), method='sparse') edge_label_index = torch.cat( [train_data.edge_label_index, neg_edge_index], dim=-1, ) edge_label = torch.cat([ train_data.edge_label, train_...
通常,一个图至少包含x, edge_index, edge_attr, y, num_nodes5个属性,当图包含其他属性时,我们可以通过指定额外的参数使Data对象包含其他的属性: graph=Data(x=x,edge_index=edge_index,edge_attr=edge_attr,y=y,num_nodes=num_nodes,other_attr=other_attr) ...
Similar to the EdgeIndex class introduced in PyG 2.5, torch-geometric==2.6.0 introduces the Index class for efficient storage of 1D indices. While Index sub-classes a general torch.Tensor, it can hold additional (meta)data, i.e.:dim_size: The size of the underlying sparse vector, i.e....
edge_index=torch.tensor(adj_matrix.nonzero(),dtype=torch.long)y=torch.tensor(labels,dtype=torch.float)data=Data(x=x,edge_index=edge_index,y=y)returndata data_list=[smiles_to_graph(s,label)fors,labelinzip(smiles,labels)]dataset=torch_geometric.data.InMemoryDataset(data_list)# 这个dataset...
edge_index=torch.tensor([# 这里表示节点0和1有连接,因为是无向图 # 那么1和0也有连接 # 上下对应着看[0,1,1,2],[1,0,2,1],],# 指定数据类型 dtype=torch.long)# 节点的属性信息 x=torch.tensor([# 三个节点 # 每个节点的属性向量维度为1[-1],[0],[1],])# 实例化为一个图结构的数据 ...