提问人:Parth 提问时间:10/18/2020 最后编辑:ZahraParth 更新时间:5/26/2021 访问量:6032
AttributeError: module 'torch' has no attribute 'hstack' [closed]
AttributeError: module 'torch' has no attribute 'hstack' [closed]
问:
我正在关注这个文档。hstack
a = torch.tensor([1, 2, 3])
b = torch.tensor([4, 5, 6])
torch.hstack((a,b))
但是我不断收到错误:
AttributeError: module 'torch' has no attribute 'hstack'
以下是导致此错误的火炬版本:
torch.__version__
'1.6.0+cpu'
我做错了什么?
答:
8赞
Poe Dator
10/18/2020
#1
显然,您正在调用一个在PyTorch版本中尚不存在的函数 - 这就是错误消息的内容。
您的链接指向与开发人员预览版相关的帮助页面:注意左上角的版本号。单击时,单击此处查看最新稳定版本的文档。链接 - 出现错误消息。.8.0a0+342069f
此功能在火炬版本中可用 - 在此之前,请考虑与 'dim=1' 一起使用。1.8.0.
torch.cat
torch.cat([a,b], dim=1) # a, b - 2d torch.Tensors
评论
1赞
user2357112
10/18/2020
torch.hstack
是一个应该存在的函数。
0赞
Poe Dator
10/18/2020
@user2357112-supports-monica, @parth-tamane: 已解决:显然您的链接指向与开发人员预览版相关的帮助页面:注意左上角的“.8.0a0+342069f”版本号。单击链接时 - 出现错误消息。因此,此功能在 1.8.0 中可用。在那之前 - 考虑使用Click here to view docs for latest stable release.
torch.cat
3赞
user2357112
10/18/2020
这可以解释它。不过,看起来它实际上在 1.7.0 中可用,而不是 1.8.0。torch.hstack
评论
torch.py