我想在torch.nn.utils层调用spectral_norm函数
gc1 = GCNConv(18, 16)
spectral_norm(gc1)
但我得到了以下错误:
KeyError: 'weight'
这意味着gc1._parameters没有权重(只是偏倚):
gc1._parameters
OrderedDict([('bias', Parameter containing:
tensor([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
requires_grad=True))])
但是,gc1参数()存储两个对象,其中一个是16×18矩阵(权重矩阵)。
for p in gc1.parameters():
print('P: ', p.shape)
P: torch.Size([16])
P: torch.Size([16, 18])
如何使spectral_norm函数在GCNConv模块上工作?
发布于 2022-01-12 19:51:52
https://stackoverflow.com/questions/70686721
复制相似问题