Closed davidissamattos closed 2 years ago
Hi @davidissamattos
Probably the issue is that you are feeding a scalar instead of a tensor. Try feeding a tensor of shape [1, 1].
auto input_vector = std::vector<float>({1.0});
auto input_tensor = cppflow::tensor(input_vector, {1, 1});
Awesome! Thanks @serizba! I did try before setting the input as a tensor but (as I realize now) I was also having runtime errors with the output (printing output instead of output[0].
For future reference, this is the working code:
#include <iostream>
#include "cppflow/cppflow.h"
int main() {
// Load the model
cppflow::model model("../tfmodel/");
// Set the input (should be a tensor)
auto input_vector = std::vector<float>({100.0});
auto input_tensor = cppflow::tensor(input_vector, {1, 1});
// Run
// Get the input and output graph nodes from saved_model_cli
auto output = model({{"serving_default_hp_input:0", input_tensor}}, {"StatefulPartitionedCall:0"});
// Show the predicted class
std::cout << output[0] << std::endl;
return 0;
}
Hi, I am trying to run ccpflow for a simple regression example and I keep getting the following error runtime error:
My model is very simple (from https://www.tensorflow.org/tutorials/keras/regression) and saved with regular save.
My cpp code also very simple
The code compiles fine and the libraries are linked with CMake on Windows. Other cppflow functions work, but I have this problem with the dimensions
Does anyone knows how to proceed? I have not seen any regression or numeric examples, only image classification. Thanks for any pointer, Best David