| 函数 | 描述 |
|---|---|
| torch::hstack | 沿着水平方向(1维度)拼接 |
| torch::vstack | 沿着竖直方向(0维度)拼接 |
| torch::dstack | 沿着第2维度方向(2维度)拼接 |
| torch::cat | 将两个张量(tensor)拼接在一起,cat是concatenate的意思,即拼接,联系在一起 |
| torch::chunk(intput,chunks,dim=0) | 把一个tensor均匀分割成若干个小tensor。 |
| torch::split(tensor,split_size,dim=0) | 沿着某维度按split_size进行分割。 |
例2-12:合并与拆分
#include#include #include using namespace torch::indexing; int main() { auto a = torch::zeros({ 2,3 }); auto b = torch::ones({4,3}); auto c = torch::range(1, 4, 1).reshape({ 2,2 }); auto d = torch::range(1, 50, 1).reshape({ 5,5,2 }); auto e = torch::r



