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 file
sseClassificationLayer.m in the current folder. For more information on constructing this layer, see Define Custom Classification Output Layer.
Create an instance of the layer.
sseClassificationLayer = sseClassificationLayer('sse');
Open Deep Network Designer with a pretrained GoogLeNet network.
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
In the Designer pane, drag a new
fullyConnectedLayer from the Layer Library onto the canvas. Set
OutputSize to the new number of classes, in this example,
Edit learning rates to learn faster in the new layers than in the transferred layers. Set
10. Delete the last fully connected layer and connect your new layer instead.
Next, replace the output layer with your custom classification output layer. Click New in the Designer pane. Pause on From Workspace and click Import. To import the custom classification layer, select
sseClassificationLayer and click OK.
Add the layer to the current GoogLeNet pretrained network by clicking Add. The app adds the custom layer to the top of the Designer pane. To see the new layer, zoom-in using a mouse or click Zoom in.
Drag the custom layer to the bottom of the Designer pane. Replace the output layer with the new classification output layer and connect the new layer.
Check your network by clicking Analyze. 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, see Transfer Learning with Deep Network Designer.