调试C ++ TensorFlow程序

时间:2018-09-10 23:13:42

标签: c++ debugging tensorflow

我正在寻找有关如何调试用c ++编写的张量流图执行的提示。特别是对session :: Run的调用会产生错误“在图形中找不到在feed_devices或fetch_devices中指定的错误”,我正在寻找调试图形的方法。

//数据是std :: vector

std::vector names = {"feature1","feature2","feature3","feature4"};

std::vector<std::pair<tf::string, tf::Tensor>> input_tensor;
std::vector<tf::Tensor> output_tensors;

//  create the Run input tensor
for (uint i=0; i < gamma_transformed_data.size();i++)
{
  tf::Tensor tensorValue(tf::DT_FLOAT, tf::TensorShape({1,1}));
  tensorValue.flat<float>().data()[0] = data[i];
  std::pair <tf::string, tf::Tensor> pair = std::make_pair (names[i],tensorValue);
  input_tensor.push_back(pair);
}


//execute the graph
check_status(ReadBinaryProto(tf::Env::Default(),protobuf_model_filepath, &graph));
check_status(tf::NewSession(tf::SessionOptions(), &session));
check_status(session->Create(graph));
check_status(session->Run(input_tensor, {"results"}, {}, &output_tensors));

session->Run returns false and status.ToString() = //"Invalid argument: Tensor xyz:0, specified in either feed_devices or fetch_devices was not found in the Graph"

0 个答案:

没有答案