unsqueeze在指定位置处插入尺寸为1的维度。
注意:返回的张量与此张量共享相同的基础数据。
Example:
>>> 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]])