serizba / cppflow

Run TensorFlow models in C++ without installation and without Bazel
https://serizba.github.io/cppflow/
MIT License
788 stars 178 forks source link

How to extract a string from tensor? #134

Closed abucka closed 2 years ago

abucka commented 3 years ago

Hi,

I have a string tensor that looks like this:

(tensor: shape=[1], data= ["0007 HMS\342\226\221\342\226\221\342\226\221"])

How can I decode and extract the string? or just extract the string and decode in C++?

abucka commented 3 years ago

when I want to extract the data using var.get_data<std::string>() I run into the sigfpe (arithmetic error) on this line from tensor.h: size_t size = TF_TensorByteSize(res_tensor) / TF_DataTypeSize(TF_TensorType(res_tensor));

I would really appreciate any help! :)

serizba commented 2 years ago

Hi @abucka

I am not quite sure right now, but I would say that you need to work with char, not with std::string.

serizba commented 2 years ago

Closing due to inactivity.