GCN object has no attribute classifier?
class GCN(torch.nn.Module): def __init__(self):
super().__init__()
torch.manual_seed(1234)
self.conv1 = GCNConv(dataset.num_features, 4)
self.conv2 = GCNConv(4, 4)
self.conv3 = GCNConv(4, 2)
def forward(self, x, edge_index):
h = self.conv1(x, edge_index)
h = h.tanh()
h = self.conv2(h, edge_index)
h = h.tanh()
h = self.conv3(h, edge_index)
h = h.tanh()
# 分类层
out = self.classifier(h)
return out, h
Traceback (most recent call last): File "C:\Users\Administrator\Desktop\projects\test.py", line 70, in <module>
_, h = model(data.x, data.edge_index)
File "C:\Program Files\Python38\lib\site-packages\torch\nn\modules\module.py", line 1190, in _call_impl
return forward_call(*input, **kwargs)
File "C:\Users\Administrator\Desktop\projects\test.py", line 63, in forward
out = self.classifier(h)
File "C:\Program Files\Python38\lib\site-packages\torch\nn\modules\module.py", line 1265, in __getattr__
raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'GCN' object has no attribute 'classifier'
以上是 GCN object has no attribute classifier? 的全部内容, 来源链接: utcz.com/p/938674.html