cppflow icon indicating copy to clipboard operation
cppflow copied to clipboard

How to create a two dimension tensor like (1000,5) (row,col)

Open fiveriddle opened this issue 3 years ago • 1 comments

I don't know whether I'm wrong or not, it seems that the cppflow::fill and cppflow::tensor can only support one dimension tensor in the example. If I'm wrong, could you please tell me where to or how to generate a 2d tensor like (1000,5) (row,col) and pass it into the model? Many thanks!

fiveriddle avatar Apr 22 '22 07:04 fiveriddle

@fiverriddle, if you would like to initialize a tensor with all elements having the same value, use the following: float val = 1.0; cppflow::tensor tnsr = cppflow::fill({ 1000, 5 }, val); If you would like to initialize a tensor with various values, do the the following: Fill a vector (1d) with the values. Then initialize the tensor with the required shape. std::vector<float> vals(1000*5); cppflow::tensor tnsr = cppflow::tensor(vals, { 1000, 5 });

yochananscharf avatar Apr 25 '22 09:04 yochananscharf

Closing due to inactivity.

serizba avatar Sep 23 '22 11:09 serizba