Python 官方文档:入门教程 => 点击学习
Torch官网解释: torch.unsqueeze(input, dim) → Tensor Returns a new tensor with a dimension of size one inserted a
torch.unsqueeze(input, dim) → Tensor
Returns a new tensor with a dimension of size one inserted at the specified position.
The returned tensor shares the same underlying data with this tensor
函数的功能是将输入增加一个维度,dim决定在哪一层增加一个维度
>>> x = torch.tensor([1, 2, 3, 4])>>> torch.unsqueeze(x, 0)tensor([[ 1, 2, 3, 4]])>>> torch.unsqueeze(x, 1)tensor([[ 1], [ 2], [ 3], [ 4]])
以下是Stack Overflow里的样例图:
来源地址:https://blog.csdn.net/weixin_45625942/article/details/127889109
--结束END--
本文标题: torch unsqueeze()详解
本文链接: https://www.lsjlt.com/news/440404.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0