torch.stack作用分析
语法
torch.stack(tensors, dim=0, *, out=None)
–> Tensor
作用
Concatenates a sequence of tensors along a new dimension.
All tensor need to be of the same size
将一个序列的tensor
在新的一维上concatenate
起来,所有tensor
的shape需要相同。
Parameters
- tensors(sequence of Tensors) – sequence of tensors to concatenate
- dim(int) – dimension to insert. Has to be between 0 and the number of dimensions of concanated tensors.
Keyword Arguments
- out(Tensor, optional) – the output tensor.