我不知道如何填充张量。 API没有很好地记录......
我希望有这样的功能。
std::tuple<std::string, double> CNNLocalizer::runImage()
{
std::tuple<std::string, double> result;
result.get<0> = "none";
result.get<1> = 0.0;
if (g_got_image_)
{
std::string label;
// create a tensorflow::Tensor with the image information
tensorflow::TensorShape image_shape;
image_shape.AddDim(g_img_height_);
image_shape.AddDim(g_img_width_);
tensorflow::Tensor input_image(tensorflow::DT_INT8, image_shape);
// I have no idea how to make this work right now. Copying data is very confusing..
for (uint i = 0; i < g_img_height_; i++)
{
for (uint j = 0; j < g_img_width_; j++)
{
// ?? Populate a matrix or something?
}
}
// Copy the matrix into the tensor?
// input_image.matrix<float>()() = z;
}
return result;
}
知道如何填充Tensor的矩阵部分吗?我找到了一个矩阵()函数,它返回某种typedef&#39; d Eigen Tensor对象 - 这是要走的路吗?
任何帮助将不胜感激!谢谢!