在 pytorch c++ API 中添加填充
Add padding in pytorch c++ API
>我有一个维度(1,3, 375, 1242)
的张量。我想通过添加填充来重塑它以(1, 3, 384, 1248)
。如何在 Pytorch c++ API 中做到这一点。提前谢谢你。
target = torch.zeros(1, 3, 384, 1248)
source = torch.ones(1, 3, 375, 1242)
target[: , : , :375, :1242] = source
您可以使用
torch::constant_pad_nd
torch::Tensor source = torch::ones(torch::IntList{1, 3, 375, 1242});
// add 6 zeros to the last dimension and 9 zeros to the third dimension
torch::Tensor target = torch::constant_pad_nd(target, IntList{0, 6, 0, 9}, 0);
相关文章:
- 将成员变量添加到共享库中的类中,不会破坏二进制兼容性吗
- 如何在C++中从两个单独的for循环中添加两个数组
- 在c++中用vector填充一个简单的动态数组
- POCO::PostgreSQL:如何将std::vector支持添加到`Binder::bind`
- 如何仅为一个函数添加延迟
- 如何使用用户输入在C++中正确填充2D数组
- 如何防止 c++ 在从浮点型转换为双精度型(不适用于 IO)时添加额外的小数?
- C++添加尾随 0 的 ostream 填充
- 在 pytorch c++ API 中添加填充
- QT-仅用密钥填充QMAP,然后添加每个键的值
- 为什么可以添加填充使您的循环更快
- 如何使用 << 添加一个空格来填充带有 ofstream 的减号?
- 准确计算编译器在结构中添加的填充
- 为什么为结构的多个数据成员而不是单个成员添加填充
- 为什么要在 C++ 结构中添加填充物
- WTableView中的QueryModel:请举例说明如何添加一行并用刚刚创建的新记录填充它
- 如何将填充零添加到写入流的数字中
- Visual C# - 引用 > 添加引用... > COM:该列表是如何填充的?
- AES_cbc_encrypt是否添加填充
- 如何在rijndael.h中添加PKCS7填充