如何向 Torch7 张量中添加一个切片?

我正在使用 Lua 和 Torch 7。

如何高效地(不使用 for 循环)将大小为 (1, 2048, 1024) 的张量 A 和 B 相加,以产生大小为 (2, 2048, 1024) 的张量 C?

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

点赞
用户4687565
用户4687565

一些函数在torch库中而不是tensorhttps://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

2018-05-16 13:33:53