serizba / cppflow

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

Reshape tensor using cppflow::reshape #232

Closed bmiftah closed 1 year ago

bmiftah commented 1 year ago

Hi , I was reshaping output of my model , which is a tensor of shape [1,224,224,1] into [224,224] using ; - auto reshaped_t = cppflow::reshape(output_tensor, [224,224],TF_FLOAT); the complier complined the foll; _error: expected ‘]’ before ‘,’ token 60 | auto reshaped_t = cppflow::reshape(output_tensor, [224,224],TFFLOAT); I tried putting shape as (224,224) - when I do this I got the follw; - Input to reshape is a tensor with 50176 values, but the requested shape has 224

50176 is multple of 224 , meaning that 224x224 = 50176 .... I don't know what I missed out here ..any help is appreacted and I thank you in advance !

serizba commented 1 year ago

Hi @bmiftah

You are mixing the syntax from python with the C++ one. In C++ there aren't multi-argument square brackets. You need to use braces instead:

auto reshaped_t = cppflow::reshape(output_tensor, {224,224}, TF_FLOAT);
bmiftah commented 1 year ago

Thank you @serizba and that worked. I will cose this issue soon but befoe that ... Is there documentation for cpplfow routines whereby I can refer template and their description so that I can avoid such mixing of syntax with what I am used to in native tensorflow.

serizba commented 1 year ago

Hi @bmiftah

You have the cppflow docs where you have examples with some basic and medium usage. For more detailed information about the functions defined in raw_ops.h you can check the source code to see the calling signature. You can also check the raw ops tf docs to understand what these functions do.

bmiftah commented 1 year ago

Thank you for that tip in your last sentence to check the corrosponding functions in the offcial docs . That helps much. This issue can be closed !