我正在尝试将 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} ]
我感谢任何反馈。
更新: 我可以通过使用数组而不是向量来解决这个问题。