如何将切片添加到 Torch7 张量?

How to add a slice to a Torch7 Tensor?

我正在使用 Lua 和 Torch 7。

我如何有效地(没有 for 循环)将大小为 (1, 2048, 1024) 的张量 A 和 B 添加到一起以生成大小为 (2, 2048, 1024) 的张量 C?

我正在使用 https://github.com/torch/torch7/blob/master/doc/tensor.md 上的包和文档,但我没有看到可以帮助我的功能。

有些函数在 torch 库中而不是 tensor https://github.com/torch/torch7/blob/master/doc/maths.md#res-torchcat-res-x_1-x_2-dimension-。 也许在连接之前需要这个函数来添加第三维: https://github.com/torch/torch7/blob/master/doc/tensor.md#result-expandresult-sizes