Tensorflow: Print contents of a tensor in C++

Viewed 9299

How do I print to screen contents of a tensor defined as below

std::vector<tensorflow::Tensor> finalOutput;

and which is assigned value by running the following operation

tensorflow::Status run_status = session->Run({{"x",input_tensor}, 
                                                       {"keep_prob", keep_prob}},
                                                      {"prediction"},
                                                      {},
                                                  &finalOutput);
2 Answers

To print a d-dimensional tensorflow::Tensor T

#define printTensor(T, d) \
    std::cout<< (T).tensor<float, (d)>() << std::endl
Related