1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > Only tensors or tuples of tensors can be output from traced functions

Only tensors or tuples of tensors can be output from traced functions

时间:2020-02-19 00:51:28

相关推荐

Only tensors or tuples of tensors can be output from traced functions

Only tensors or tuples of tensors can be output from traced functions

错误代码:

heads = {'hm': 5, 'wh': 2, 'hps': 2}model= get_pose_net(34,heads,64)# model = torch.load('34.weights')# model.cuda()model.eval()example = torch.rand(1, 3, 512, 512)traced_script_module = torch.jit.trace(model, example)traced_script_module.save("cxx_model.pt")def forward(self, x):x = self.conv1(x)x = self.bn1(x)x = self.relu(x)x = self.maxpool(x)x = self.layer1(x)x = self.layer2(x)x = self.layer3(x)x = self.layer4(x)print("out",x.size())x = self.deconv_layers(x)ret = {}for head in self.heads:ret[head] = self.__getattr__(head)(x)return [ret]

原因:结果只能输出tensors or tuples of tensors

centernet中,返回的是字典,是不支持的。

解决方法:

想办法把返回的字典变成 tensors,就可以了。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。