【发布时间】:2019-09-19 03:15:19
【问题描述】:
我正在训练一个学习一些权重的神经网络,并根据这些权重计算转换,从而产生与权重相结合的预测模型。我的网络没有正确学习,因此我正在编写一个不同的网络,它只返回独立于输入x 的权重(在使用 softmax 和转置进行标准化之后)。这样,我想找出问题出在网络上还是出在网络外的变换估计上。但这不起作用。这就是我所拥有的。
class DoNothingNet(torch.nn.Module):
def __init__(self, n_vertices=6890, n_joints=14):
super(DoNothingNet, self).__init__()
self.weights = nn.parameter.Parameter(torch.randn(n_vertices, n_joints))
def forward(self, x, indices):
self.weights = F.softmax(self.weights, dim=1)
return self.weights.transpose(0,1)
但是self.weights = F.softmax(self.weights, dim=1) 行不起作用并产生错误TypeError: cannot assign 'torch.cuda.FloatTensor' as parameter 'weights' (torch.nn.Parameter or None expected)。我该如何解决?代码是否有意义?
【问题讨论】:
标签: python neural-network pytorch