libprotobuf map.h error when running universal sentence encoder
JZacaroli opened this issue · comments
I'm trying to embed a string using the universal sentence encoder, but I'm hitting this error when running the model:
[libprotobuf FATAL external/com_google_protobuf/src\google/protobuf/map.h:1293] CHECK failed: it != end(): key not found: value
I'm compiling like so (using windows):
g++ -std=c++17 -I/path/to/libtensorflow-cpu-windows-x86_64-2.15.0/include -I/path/to/cppflow-master/include -L/path/to/libtensorflow-cpu-windows-x86_64-2.15.0/lib hello_tf.cpp -ltensorflow -o hello_tf
This is hello_tf.cpp:
#include <iostream>
#include <tensorflow/c/c_api.h>
#include <cppflow/cppflow.h>
int main() {
printf("Hello from TensorFlow C library version %s\n", TF_Version());
cppflow::model model("model-use");
auto input = cppflow::reshape(cppflow::tensor(std::string("hello")), {-1});
std::cout << input << std::endl;
auto output_tensor = model({{"serving_default_inputs:0", input}},{"StatefulPartitionedCall_1:0"}); // <-- Line causing the error
return 0;
}
This is the output of the saved_model_cli command on the saved model .pb file:
The given SavedModel SignatureDef contains the following input(s):
inputs['inputs'] tensor_info:
dtype: DT_STRING
shape: (-1)
name: serving_default_inputs:0
The given SavedModel SignatureDef contains the following output(s):
outputs['outputs'] tensor_info:
dtype: DT_FLOAT
shape: (-1, 512)
name: StatefulPartitionedCall_1:0
Method name is: tensorflow/serving/predict
If I change "serving_default_inputs:0" to "serving_default_inputs" and "StatefulPartitionedCall_1:0" to "StatefulPartitionedCall" when calling the model, then it doesn't fail, and instead returns this: (tensor: shape=[], dtype=TF_FLOAT, data=1)
. I am hoping to get a 512 dimensional vector out of it.
Any help is very much appreciated!
I've managed to get this working by using tensorflow v2.10, instead of v2.15. Not sure why this works though..
The tensorflow download page mentions v2.10 being the latest version that's supported GPU on windows, but just I'm using the CPU version.
Doesn't seem like an issue with cppflow, but I'll leave this up in case someone can explain what the protobuf error is about.