Main Content

coder.loaddeeplearningnetwork

Load deep learning network model

描述

net= coder.loadDeepLearningNetwork(文件名加载预定的深度学习系列网络(深度学习工具箱),,,,dagnetwork(深度学习工具箱),,,,Yolov2ObjectDetector(计算机视觉工具箱), 或者ssdobjectDetector(计算机视觉工具箱)目的saved in the文件名MAT-file.文件名必须是MATLAB上存在的有效垫子文件®包含单个的路径系列网络,,,,dagnetwork,,,,Yolov2ObjectDetector, 或者ssdobjectDetector目的。垫子文件必须仅包含要加载的网络。

例子

net= coder.loadDeepLearningNetwork(函数名称调用一个返回经过预定深入学习的功能系列网络,,,,dagnetwork,,,,Yolov2ObjectDetector, 或者ssdobjectDetector目的。函数名称must be the name of a function existing on the MATLAB path that returns a系列网络,,,,dagnetwork,,,,Yolov2ObjectDetector, 或者ssdobjectDetector目的。

例子

net= coder.loadDeepLearningNetwork(___,,,,网络名字是相同的net = coder.loaddeeplearningnetwork(文件名)可以选择命名从网络生成的C ++类。网络名字is a descriptive name for the network object saved in the MAT-file or pointed to by the function. The network name must be achar类型是C ++中的有效标识符。

Use this function when generating code from a network object inference. This function generates a C++ class from this network. The class name is derived from the MAT-file name or the function name.

笔记

输入参数coder.loaddeeplearningnetwork必须是编译时常数。

例子

全部收缩

Use of thecoder.loaddeeplearningnetworkfunction to load anVGG-16series network and generate C++ code for this network.

Get the MAT-file containing the pretrainedVGG-16network.

url ='//www.tianjin-qmedu.com/supportfiles/gpucoder/cnn_models/VGG/vgg16.mat';WebSave('vgg16.mat',,,,url);

创建一个n entry-point functionmyVGG16使用coder.loaddeeplearningnetworkfunction to load thevgg16.matinto the persistentmynet系列网络目的。

functionout = myvgg16(in)执着的mynet;如果isempty(mynet) mynet = coder.loadDeepLearningNetwork('vgg16.mat',,,,'myvggnet');结尾out =预测(mynet,in);

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

这input layer of the pretrainedVGG-16网络接受大小的图像224x224x3。使用以下代码行读取从图形文件中读取输入映像,然后将其调整为224x224

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

创建一个coder.configMEX代码生成的配置对象,并将目标语言设置为C ++。On the configuration object, setDeepLearningConfig靶标作为'mkldnn'。这代码根功能必须确定MATLAB函数输入的大小,类和复杂性。使用-args选项指定输入点功能的输入大小。使用-config选项传递代码配置对象。

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

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

称呼VGG-16预测输入图像并显示前五名的标签。

predict_scores = myVGG16_mex(in); [scores,indx] = sort(predict_scores,“下降”);net = coder.loaddeeplearningnetwork('vgg16.mat');classNames = net.layers(end).classes;disp(classNames(indx(1:5)));
贝尔胡椒黄瓜杂货店橡子南瓜南瓜

Use of thecoder.loaddeeplearningnetworkfunction to load anresnet50系列网络并生成CUDA®该网络的代码。

创建一个n entry-point functionResnetFun使用coder.loaddeeplearningnetworkfunction to call the Deep Learning Toolbox™ toolbox functionresnet50。此功能返回预定的ResNet-50network.

functionout = resnetfun(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.gpuconfigMEX代码生成的配置对象,并将目标语言设置为C ++。这代码根功能必须确定MATLAB函数输入的大小,类和复杂性。使用-args选项指定输入函数的输入大小,-config选项传递代码配置对象。

cfg = coder.gpuconfig('Mex');cfg.targetlang ='C ++';cfg.deeplearningconfig = coder.deeplearningconfig('cudnn');代码根-args{一个(224,224,3,'uint8')}-configCFGResnetFun-report;

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

输入参数

全部收缩

Specifies the name of the MAT-file containing the pretrained系列网络,,,,dagnetwork,,,,Yolov2ObjectDetector, 或者ssdobjectDetector目的。

This input argument must be a compile-time constant.

数据类型:细绳

指定返回预定的功能的名称系列网络,,,,dagnetwork,,,,Yolov2ObjectDetector, 或者ssdobjectDetector目的。

This input argument must be a compile-time constant.

数据类型:细绳

保存在垫子文件中的网络对象的描述性名称。它一定是一个char类型是C ++中的有效标识符。

This input argument must be a compile-time constant.

数据类型:char

输出参数

全部收缩

网络推断,返回系列网络,,,,dagnetwork,,,,Yolov2ObjectDetector, 或者ssdobjectDetector目的。

Limitations

  • coder.loaddeeplearningnetwork不支持多个网络加载万博1manbetx垫子。

  • 垫子文件必须仅包含要加载的网络。

扩展功能

C/C ++代码生成
Generate C and C++ code using MATLAB® Coder™.

GPU代码生成
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.

版本历史记录

在R2017b中引入