Main Content

coder.DeepLearningConfig

创建深度学习代码生成配置对象

描述

例子

深度学习= coder.deeplearningconfig(targetLibrary =靶标creates a deep learning configuration object containing library-specific parameters that代码根用于生成深层神经网络的代码。将此深度学习配置对象分配给深度学习通过使用代码配置对象的属性coder.config。将代码配置对象传递给代码根通过使用-configoption.

例子

全部收缩

设置代码配置参数并生成一个C ++代码Resnet-50系列网络。生成的代码使用英特尔®MKL-DNN deep learning libraries.

创建一个入口点功能resnet_predict使用coder.loaddeeplearningnetworkfunction to load theresnet50(深度学习工具箱)系列网络object.

functionout = resnet_predict(in)执着的mynet;如果isempty(mynet) mynet = coder.loadDeepLearningNetwork('resnet50',,,,“ myResnet”);结尾out =预测(mynet,in);

持续的对象避免在随后的调用函数调用以调用该函数时重建和重新加载网络对象predictmethod on the input.

这input layer of the pretrainedResnet-50网络接受大小的图像224x224x3。To read an input image from a graphics file and resize it to224x224,使用以下代码行:

in = imread('peppers.png');in = imresize(in,[224,224]);

创建一个coder.configconfiguration object for MEX code generation and set the target language to C++. On the configuration object, set深度学习靶标作为'mkldnn'。使用-config选项代码根function to pass this code configuration object. The代码根function must determine the size, class, and complexity of MATLAB®function inputs. Use the-args选项指定输入点功能的输入大小。

cfg = coder.config('Mex');cfg.targetlang ='C ++';cfg.deeplearningconfig = coder.deeplearningconfig(targetLibrary ='mkldnn');代码根-args{一个(224,224,3,'single')}-configCFGresnet_predict;

代码根命令将所有生成的文件放在代码根文件夹。它包含入口点功能的C ++代码resnet_predict。cpp,,,,header and source files containing the C++ class definitions for the convoluted neural network (CNN), weight, and bias files.

输入参数

全部收缩

Target library for deep learning code generation, specified as one of the values in this table.

Value 描述
'没有任何'

用于生成不使用任何第三方库的代码。

“手臂计算”

用于生成使用手臂的代码®计算库。

'mkldnn'

用于生成使用英特尔数学内核库进行深神经网络(Intel MKL-DNN)的代码。

'CMSIS-NN

Common Microcontroller Software Interface Standard - Neural Network (CMSIS-NN) library.

需要MATLAB CODER™界面,用于深度学习库

'cudnn'

用于生成使用CUDA的代码®深神经网络图书馆(Cudnn)。

此选项需要GPU CODER™。

'tensorrt'

为了生成利用NVIDIA的代码®TensorRT – high performance deep learning inference optimizer and run-time library.

此选项需要GPU编码器。

输出参数

全部收缩

基于输入参数中指定的目标库的配置对象。该对象包含在代码生成过程中使用的特定于库的参数。

Target Library 深度学习配置对象
'没有任何' 创建一个深度学习configbase配置对象。
“手臂计算” 创建一个Armneonconfig配置对象。
'mkldnn' 创建一个mkldnnconfig配置对象。
'CMSIS-NN 创建一个cmsisnnconfig配置对象。
'cudnn' 创建一个CuDNNConfig配置对象。
'tensorrt' 创建一个TensorRTConfig配置对象。

版本历史记录

在R2018B中引入