View Autogenerated Custom Layers Using Deep Network Designer
This example shows how to import a pretrained TensorFlow™ network and view the autogenerated layers in Deep Network Designer.
Import a pretrained TensorFlow network in the saved model format as a DAGNetwork
object. The imported network contains layers that are not supported for conversion into built-in MATLAB® layers. The software automatically generates custom layers when you import these layers.
Specify the model folder.
if ~exist("digitsDAGnetwithnoise","dir") unzip("digitsDAGnetwithnoise.zip") end modelFolder = "./digitsDAGnetwithnoise";
Specify the class names.
classNames = {'0','1','2','3','4','5','6','7','8','9'};
Import a TensorFlow™ network in the saved model format. By default, importTensorFlowNetwork
imports the network as a DAGNetwork
object. Specify the output layer type for an image classification problem.
net = importTensorFlowNetwork(modelFolder, ... OutputLayerType="classification", ... Classes=classNames);
Importing the saved model... Translating the model, this may take a few minutes... Finished translation. Assembling network... Import finished.
View the network in Deep Network Designer.
deepNetworkDesigner(net)
If the imported network contains layers not supported for conversion into built-in MATLAB layers, then the importTensorFlowNetwork
function can automatically generate custom layers in place of these layers. importTensorFlowNetwork
saves each generated custom layer to a separate .m
file in the package +digitsDAGnetwithnoise
in the current folder.
The autogenerated layers appear in the Deep Network Designer canvas as gray icons with names starting with "k". Select a layer to see more information about its properties.
You can view and edit the layer code by clicking Edit Layer Code. The class file opens in the MATLAB® Editor.
See Also
Deep Network Designer | trainingOptions
| trainNetwork
| importTensorFlowNetwork