CUDA, Keras2Cpp [closed]

  c++, cuda, github

I am working using a GitHub repository:- https://github.com/gosha20777/keras2cpp
To use my dumped Tensorflow model in C++ and apply CUDA in it.

I am trying to infer a single sample of dimensions (1,28,28,1). Since my dumped model accepts in this format.

I did the following to initialize my data:-

Tensor in{1}{28}{28}{1}; // Creating a 4 dim. test Sample :- Batch_Size = 1, Image_Dim = (28,28), Channel = 1 (for greysacle image)
in.data_ = {{{{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}}
{{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}}
{{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}}
{{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}}
{{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}}
{{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{1.0}{1.0}{1.0}{1.0}{1.0}{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.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}}}};

But I am getting a lot of errors. Which are like these,

Tensor in{1}{28}{28}{1}; // Creating a 4 dim. test Sample :- Batch_Size = 1, Image_Dim = (28,28), Channel = 1 (for greysacle image)
^
/home/ghosh8/project/Demo/keras2cpp/cpp_model.cc:12:25: error: expected ‘;’ before ‘}’ token
Tensor in{1}{28}{28}{1}; // Creating a 4 dim. test Sample :- Batch_Size = 1, Image_Dim = (28,28), Channel = 1 (for greysacle image)

/home/ghosh8/project/Demo/keras2cpp/cpp_model.cc:13:26: error: expected ‘;’ before ‘{’ token
in.data_ = {{{{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}}

/home/ghosh8/project/Demo/keras2cpp/cpp_model.cc:14:20: error: expected unqualified-id before ‘{’ token
{{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}{0.0}}

Could anyone help what I am doing wrong………………?

Source: Windows Questions C++

LEAVE A COMMENT