Kevin - 9 months ago 78

C++ Question

I have a tensor that I would like to print for debugging

`tensorflow::Tensor image_tensor;`

I tried

`std::cout << &image_tensor;`

But I get something like this:

`0x16fd81cf8I`

Answer

you have to use the .vec or .flat methods.
let’s say the tensor is a `int8`

```
// for i in image_tensor.size …
cout << i << “ “ << image_tensor.vec<int8>()(i)
```

see also this answer How to fill a tensor in C++

Source (Stackoverflow)