将 2d 矢量转换为 torch::tensor 在 C++ 中没有正确的数据

问题描述 投票:0回答:1

我正在尝试将 2d 向量转换为 c++ 中的火炬张量,但输出没有正确的数据:

std::vector<std::vector <int>> indx1 = {{126, 22}, {166, 102}, {46, 46}, {166, 54} };
auto indx_options = torch::TensorOptions().dtype(torch::kInt32);
auto indx = torch::from_blob(indx1.data(), {indx1.size(),2}, indx_options);

输出:

 1.1586e+09  2.2036e+04
 1.1586e+09  2.2036e+04
 1.1586e+09  2.2036e+04
 1.1586e+09  2.2036e+04
[ CPUIntType{4,2} ]

我感谢任何反馈。

c++ vector torchscript
1个回答
0
投票

更新: 我可以通过使用数组而不是向量来解决这个问题。

© www.soinside.com 2019 - 2024. All rights reserved.