Closed A11en0 closed 3 years ago
我自己使用Pyg实现了一下,效果很差,不知道是否是我代码的问题?
I used Pyg to implement it myself, and the effect is very poor. I don't know if it is the problem with my code?
class GCN(torch.nn.Module):
def __init__(self, nfeat, nhid, nclass, dropout):
super(GCN, self).__init__()
self.conv1 = GCNConv(nfeat, nhid, normalize=True)
self.conv2 = GCNConv(nhid, nclass, normalize=True)
self.dropout = dropout
def forward(self, x, edge_index, edge_weight, batch):
x = F.relu(self.conv1(x, edge_index, edge_weight))
x = torch.dropout(x, self.dropout, train=self.training)
x = self.conv2(x, edge_index, edge_weight)
x = global_max_pool(x, batch)
return F.log_softmax(x, dim=1)
Edit: 刚刚没有加Glove,加上后在MR上达到73%左右。
直接使用GateGCN,loss异常,为负值:
class GateGCN(torch.nn.Module):
def __init__(self, nfeat, nhid, nclass, dropout):
super(GateGCN, self).__init__()
self.gateconv = GatedGraphConv(out_channels=300, num_layers=3, aggr='add')
def forward(self, x, edge_index, edge_weight, batch):
x = self.gateconv(x, edge_index, edge_weight)
h = global_max_pool(x, batch)
return h
我使用pytorch实现代码,细节和作者一模一样,只有mr和R8有一定结果,而且准确率也差了几个点,R52和ohsumed目前还没有训练出来结果
@A11en0
您好,我个人之前使用GCN也没能取得很好效果,可能是GCN聚合方式较为简单,而小图的信息又比较有限,Gate更有利于信息的抽取;关于自环,默认是去掉自环的,因为Gate机制中已经带有上一状态。
Hi, I tried GCN and didn't get desired results before. I guess the aggregation operation in GCN is too straightforward to incorporate enough messages in each individual graph, while Gate can. And the model doesn't have the self-loop because the Gate mechanism already contains that.
@Huasheng-hou
您好,这里有一篇非官方的torch版本,供参考 https://blog.csdn.net/qq_28969139/article/details/107849798
@Huasheng-hou
您好,这里有一篇非官方的torch版本,供参考 https://blog.csdn.net/qq_28969139/article/details/107849798
非常感谢,我试试
@A11en0
您好,我个人之前使用GCN也没能取得很好效果,可能是GCN聚合方式较为简单,而小图的信息又比较有限,Gate更有利于信息的抽取;关于自环,默认是去掉自环的,因为Gate机制中已经带有上一状态。
Hi, I tried GCN and didn't get desired results before. I guess the aggregation operation in GCN is too straightforward to incorporate enough messages in each individual graph, while Gate can. And the model doesn't have the self-loop because the Gate mechanism already contains that.
感谢回复!我个人的一些发现,欢迎指正:
Thanks Reply! Some of my personal findings, please correct me:
It is very important to use Glove to initialize the node features, which may be due to the inability to learn the features well in the one-hot encoding in the small graph.
I understand that whether it is GCN or GGCN, it only functions as an encoder. In fact, the reason why this article works well is more due to the existence of readout? I wonder if ablation has been performed?
@A11en0
readout确实是比较重要的一部分,因为这里把节点分类问题变成了图分类问题,不可避免地需要引入readout, 也没有做消融。
Yes, the readout is quite important, as the task becomes a graph classification problem rather than a node classification problem. And no ablation study on it.
您好,感谢您有价值的工作!
Hello, thank you for your valuable work!