%% Code Generation for Deep Learning Networks
%
% This example shows how to perform code generation for an image
% classification application that uses deep learning. It uses the |codegen|
% command to generate a MEX function that runs prediction by using image
% classification networks such as MobileNet-v2, ResNet, and GoogLeNet.
%
%% Third-Party Prerequisites
% Required
%
% This example generates CUDA MEX and has the following third-party
% requirements.
%
% * CUDA® enabled NVIDIA® GPU and compatible driver.
%
% Optional
%
% For non-MEX builds such as static, dynamic libraries or executables,
% this example has the following additional requirements.
%
% * NVIDIA toolkit.
% * NVIDIA cuDNN library.
% * Environment variables for the compilers and libraries. For more
% information, see
% <docid:gpucoder_gs#mw_aa8b0a39-45ea-4295-b244-52d6e6907bff Third-party
% Products> and <docid:gpucoder_gs#mw_453fbbd7-fd08-44a8-9113-a132ed383275
% Environment Variables>.
%% Verify GPU Environment
% Use the <docid:gpucoder_ref#mw_0957d820-192f-400a-8045-0bb746a75278 coder.checkGpuInstall> function
% to verify that the compilers and libraries necessary for running this example
% are set up correctly.
envCfg = coder.gpuEnvConfig(‘host’);
envCfg.DeepLibTarget = ‘cudnn’;
envCfg.DeepCodegen = 1;
envCfg.Quiet = 1;
coder.checkGpuInstall(envCfg);
%% |mobilenetv2_predict| Entry-Point Function
%
% MobileNet-v2 is a convolutional neural network that is trained on more
% than a million images from the ImageNet database. The network is 155
% layers deep and can classify images into 1000 object categories, such as
% keyboard, mouse, pencil, and many animals. The network has an image
% input size of 224-by-224. Use the <docid:nnet_ref#mw_8d52b67d-b6b3-4c62-b573-56fdf4dce6a0 analyzeNetwork>
% function to display an interactive visualization of the dee