Set the code configuration parameters and generate C++ code for an
ResNet-50
series network. The generated code uses the Intel® MKL-DNN deep learning libraries.
Create an entry-point function resnet_predict
that uses the
coder.loadDeepLearningNetwork
function to load the resnet50
(Deep Learning Toolbox)
SeriesNetwork
object.
The persistent object avoids reconstructing and reloading the network object during
subsequent calls to the function to invoke the predict
method on the
input.
The input layer of the pretrained ResNet-50
network accepts
images of size 224x224x3
. To read an input image from a graphics file
and resize it to 224x224
, use the following lines of code:
Create a coder.config
configuration object for MEX code
generation and set the target language to C++. On the configuration object, set
DeepLearningConfig
with targetlib
as
'mkldnn'
. Use the -config
option of the
codegen
function to pass this code
configuration object. The codegen
function must determine the size,
class, and complexity of MATLAB® function inputs. Use the -args
option to specify the
size of the input to the entry-point function.
The codegen
command places all the generated files in the
codegen
folder. It contains the C++ code for the entry-point
function resnet_predict.cpp
, header and source files containing the
C++ class definitions for the convoluted neural network (CNN), weight, and bias
files.