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

Connect tensor #206

Open xiaojun-mbed opened 1 year ago

xiaojun-mbed commented 1 year ago

How do I connect two tensors?

std::vector vals1 = { 1.1, 1.2, 1.3, 1.4, 1.5, 1.6,1.7, 1.8, 1.9 }; std::vector vals2 = { 1.11, 1.21, 1.31, 1.41, 1.51, 1.61,1.71, 1.81, 1.91 }; cppflow::tensor t1 = cppflow::tensor(vals1, { 9,1 }); cppflow::tensor t2 = cppflow::tensor(vals2, { 9,1 });

Connect like this in the dimension of axis = 1 to form a tensor of shape dimension (9, 2)

serizba commented 1 year ago

Hi @xiaojun-mbed

CppFlow provides a mapping of TF Raw Ops in cppflow/raw_ops.h.

You can use the mapping of concat:

tensor concat(const tensor& concat_dim, const std::vector<tensor>&values)
xiaojun-mbed commented 1 year ago

Thank you very much for your help! I can't understand the source code. Can you tell me how to do this example

cppflow::tensor add = cppflow::concat(1, vector(t1,t2));

image

serizba commented 1 year ago

It looks fine. You didn't post the error you getting so is hard to tell.