torch.stack()

跟torch.scatter()类似,scatter()请看我的上一篇博客:https://blog.csdn.net/weixin_43496455/article/details/103870889

贴个torch.stack()官方文档的截图
torch.stack()详解

dim代表沿着哪个维度进行堆叠

举个例子:

dim=0时:(dim不写时,默认为0)

torch.stack()详解

a: 2x3 ; b: 2x3 ; c: 2x2x3

torch.stack()详解

dim=2时:略

dim=3时:

torch.stack()详解

a: 2x3 ; b: 2x3 ; c: 2x3x2

torch.stack()详解

总结

torch.stack()详解

相关文章: