Question:
I want to load kernels/weights of each CNN layer into vectors such as vector<vector<float>>
, used in C++ applications.
For example, given such a CNN structure (MNIST dataset), how to extract the kernels (7*7*4
) in the first convolution layer into vector<vector<vector<float>>>
?
Layer: Description:
Convolution Input image 28*28, kernel size 7*7, stride size of 3, number of
output channels 4
The CNN model is trained using Keras and saved in the files such as mnistCNN.h5
.
Similar questions like Running trained TensorFlow model in C++ only support loading the saved model and making predictions in C++. We cannot extract the parameters of each layer in their implementation.
So is there any example code for doing this?