【发布时间】:2016-11-10 03:37:04
【问题描述】:
我不知道如何填充张量。 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;
}
知道如何填充张量的矩阵部分吗?我找到了一个 matrix() 函数,它返回某种类型定义的 Eigen Tensor 对象 - 这是要走的路吗?
任何帮助将不胜感激!谢谢!
【问题讨论】:
标签: c++ tensorflow