analyzeNetworkForCodegen
说明
___ = analyzeNetworkForCodegen(___, 通过使用由一个或多个 Name,Value)Name,Value 对组参量指定的选项,分析深度学习网络 net 以进行代码生成。
示例
此示例使用:
- Deep Learning ToolboxDeep Learning Toolbox
- Deep Learning Toolbox Model for MobileNet-v2 NetworkDeep Learning Toolbox Model for MobileNet-v2 Network
- GPU Coder Interface for Deep LearningGPU Coder Interface for Deep Learning
- MATLAB Coder Interface for Deep LearningMATLAB Coder Interface for Deep Learning
此示例说明如何使用 analyzeNetworkForCodegen 函数检查 MobileNet-v2 网络的代码生成兼容性。
您可以使用 analyzeNetworkForCodegen 函数来确定以各种 CPU 和 GPU 深度学习库为目标时的网络和层兼容性问题。
下载 MobileNet-v2 支持包
此示例使用通过 Deep Learning Toolbox™ Model for MobileNet-v2 Network 支持包提供的 MobileNet-v2 的预训练版本。
MobileNet-v2 是深度为 53 层的卷积神经网络。该网络的预训练版本是基于 ImageNet 数据库中的超过一百万个图像进行训练的。预训练网络的图像输入大小为 224×224,它可以将图像分类至 1000 个目标类别(例如键盘、鼠标、铅笔和多种动物)。
mobilenetv2 = imagePretrainedNetwork('mobilenetv2')mobilenetv2 =
dlnetwork with properties:
Layers: [153×1 nnet.cnn.layer.Layer]
Connections: [162×2 table]
Learnables: [210×3 table]
State: [104×3 table]
InputNames: {'input_1'}
OutputNames: {'Logits_softmax'}
Initialized: 1
View summary with summary.
如果未安装 Deep Learning Toolbox Model for MobileNet-v2 Network 支持包,该函数将在附加功能资源管理器中提供所需支持包的链接。要安装支持包,请点击链接,然后点击安装。
分析用于代码生成的网络
运行 analyzeNetworkForCodegen 函数以分析 mobilenetv2,并指定要分析的目标库。analyzeNetworkForCodegen 函数需要 MATLAB® Coder™ Interface for Deep Learning 和 GPU Coder™ Interface for Deep Learning 支持包。要安装所需的支持包,请使用附加功能资源管理器。
targetLibraries = ["none","cudnn","tensorrt","mkldnn","arm-compute",... "arm-compute-mali","cmsis-nn"]; S = analyzeNetworkForCodegen(mobilenetv2,TargetLibrary = targetLibraries);
Supported LayerDiagnostics
_________ _______________________________________________________________________________________________________________________________________________________________________________
none "Yes" ""
cudnn "Yes" ""
tensorrt "Yes" ""
mkldnn "Yes" ""
arm-compute "Yes" ""
arm-compute-mali "Yes" ""
cmsis-nn "No" "Found 6 unsupported layer types. View incompatible layer types."
要访问 CMSIS-NN 目标的分析结果,请使用以下命令。
disp(S(7))
TargetLibrary: 'cmsis-nn'
Supported: 0
NetworkDiagnostics: [0×0 table]
LayerDiagnostics: [150×3 table]
IncompatibleLayerTypes: [6×1 string]
显示 CMSIS-NN 代码生成不支持的层类型。
S(7).IncompatibleLayerTypes
ans = 6×1 string
"AdditionLayer"
"BatchNormalizationLayer"
"ClippedReLULayer"
"Convolution2DLayer"
"GlobalAveragePooling2DLayer"
"GroupedConvolution2DLayer"
输入参数
要针对代码生成进行分析的网络。网络可以是 dlnetwork、SeriesNetwork 或 DAGNetwork 对象,用于自定义训练循环或自定义剪枝循环。
名称-值参数
将可选的参量对组指定为 Name1=Value1,...,NameN=ValueN,其中 Name 是参量名称,Value 是对应的值。名称-值参量必须出现在其他参量后,但参量对组的顺序无关紧要。
示例: resultStruct = analyzeNetworkForCodegen(imagePretrainedNetwork("mobilenetv2"), TargetLibrary = ["none", "mkldnn"]);
深度学习代码生成的目标库,指定为下表中的值之一。
| 值 | 描述 |
|---|---|
"none" | 用于生成不使用任何第三方库的代码。 |
"arm-compute" | 用于生成使用 ARM® Compute Library 的代码。 |
"mkldnn" | 用于生成使用 Intel® Math Kernel Library for Deep Neural Networks (Intel MKL-DNN) 的代码。 |
"cmsis-nn" | 通用微控制器软件接口标准 - 神经网络 (CMSIS-NN) 库。 需要 MATLAB® Coder™ Interface for Deep Learning。 |
"cudnn" | 用于生成使用 CUDA® 深度神经网络库 (cuDNN) 的代码。 此选项需要 GPU Coder™。 |
"tensorrt" | 用于生成使用 NVIDIA® TensorRT(高性能深度学习推断优化器和运行时库)的代码。 此选项需要 GPU Coder。 |
用于隐藏报告显示的标量 boolean 值。默认情况下,该函数以详尽模式显示分析结果。
输出参量
检查深度学习网络的代码生成兼容性的结果,以 1×N 结构体形式返回,其中 N 是要检查的目标库的数量。
版本历史记录
在 R2022b 中推出
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)