Main Content

Import Custom Layer into Deep Network Designer

This example shows how to import a custom classification output layer with the sum of squares error (SSE) loss and add it to a pretrained network in Deep Network Designer.

Define a custom classification output layer. To create this layer, save the filesseClassificationLayer.min the current folder. For more information on constructing this layer, seeDefine Custom Classification Output Layer

Create an instance of the layer.

sseClassificationLayer = sseClassificationLayer ('sse');

Open Deep Network Designer with a pretrained GoogLeNet network.

deepNetworkDesigner(googlenet);

To adapt a pretrained network, replace the last learnable layer and the final classification layer with new layers adapted to the new data set. In GoogLeNet, these layers have the names'loss3-classifier'and'output', respectively.

In theDesignerpane, drag a newfullyConnectedLayerfrom theLayer Libraryonto the canvas. SetOutputSizeto the new number of classes, in this example,2

Edit learning rates to learn faster in the new layers than in the transferred layers. SetWeightLearnRateFactorandBiasLearnRateFactorto10。Delete the last fully connected layer and connect your new layer instead.

Next, replace the output layer with your custom classification output layer. ClickNewin theDesignerpane. Pause onFrom Workspaceand clickImport。导入自定义分类层,selectsseClassificationLayerand clickOK

Add the layer to the current GoogLeNet pretrained network by clickingAdd。The app adds the custom layer to the top of theDesignerpane. To see the new layer, zoom-in using a mouse or clickZoom in

Drag the custom layer to the bottom of theDesignerpane. Replace the output layer with the new classification output layer and connect the new layer.

Check your network by clickingAnalyze。The network is ready for training if Deep Learning Network Analyzer reports zero errors.

After you construct your network, you are ready to import data and train. For more information on importing data and training in Deep Network Designer, seeTransfer Learning with Deep Network Designer

See Also

Related Topics