Closed JohnMrziglod closed 3 years ago
Hi @JohnMrziglod
You are feeding the model with a tensor with shape=[]
, that is, a scalar. But the model requires a vector shape=[-1]
. You can convert the scalar into a vector with the cppflow::reshape
method. Note the difference between both:
std::cout << cppflow::tensor(std::string("hello")) << std::endl;
// (tensor: shape=[], data="hello")
std::cout << cppflow::reshape(cppflow::tensor(std::string("hello")), {-1}) << std::endl;
// (tensor: shape=[1], data=["hello"])
If you need a vector with multiple strings, you can use cppflow::concat
:
auto s1 = cppflow::tensor(std::string("hello"));
auto s2 = cppflow::tensor(std::string("hello"));
auto s3 = cppflow::tensor(std::string("hello"));
std::cout << cppflow::concat(0, {s1, s2, s3});
// (tensor: shape=[3], data=["hello" "hello" "hello"])
Hope it helps!
Amazing, thank you!
Amazing library! Thank you very much for creating it.
I am trying to use cppflow with the Universal Sentence Encoder model. Unfortunately, I am not sure how to pass a vector of strings to the model. This is the code I use:
This fails with
How do I pass a vector of strings to this model?