【发布时间】:2021-10-12 20:16:13
【问题描述】:
在this 示例中,我们看到nn.Module 的以下实现:
class Net(torch.nn.Module):
def __init__(self, in_channels, hidden_channels, out_channels):
super().__init__()
self.conv1 = GCNConv(in_channels, hidden_channels)
self.conv2 = GCNConv(hidden_channels, out_channels)
def encode(self, x, edge_index):
x = self.conv1(x, edge_index).relu()
return self.conv2(x, edge_index)
def decode(self, z, edge_label_index):
return (z[edge_label_index[0]] * z[edge_label_index[1]]).sum(dim=-1)
def decode_all(self, z):
prob_adj = z @ z.t()
return (prob_adj > 0).nonzero(as_tuple=False).t()
但是,在docs 中,我们有'forward(*input)'“应该被所有子类覆盖。”
为什么在这个例子中不是这样?
【问题讨论】: