简体   繁体   English

tensorflow c++中的张量怎么填?

[英]How to fill the tensor in tensorflow c++?

I am loading the.pb file in tensorflow c++.我正在加载 tensorflow c++ 中的 .pb 文件。 Now I need to fill the input tensor with my data and get the output tensors.现在我需要用我的数据填充输入张量并获得 output 张量。

To fill data, I am using below code:要填充数据,我使用以下代码:

tensorflow::Tensor points_tensor{tensorflow::DataType::DT_FLOAT, tensorflow::TensorShape({number_of_points,4})};
    auto pointsMapped = points_tensor.tensor<float, 2>();
    for(int i=0; i<number_of_points; i++){
        //to the shifting here only
    pointsMapped(i,0) = point_cloud.points[i].x;
    pointsMapped(i,1) = point_cloud.points[i].y;
    pointsMapped(i,2) = point_cloud.points[i].z;
    pointsMapped(i,3) = point_cloud.points[i].intensity;
    }

point_cloud is a vector of point object. point_cloud 是点 object 的向量。

But I do not think so, it is better way to do it in c++.但我不这么认为,最好在 c++ 中做到这一点。 Because I need to access my tensor shape so.因为我需要访问我的张量形状。

Can someone help me with this?有人可以帮我弄这个吗?

Actually The above mentioned method is the better way to fill the tensor in tensorflow实际上上面提到的方法是填充tensorflow中张量的更好方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM