MATLAB: Can we only train the classification layer when do transfer learning of a pre-trained network

Deep Learning Toolboxtransfer learning deep neural network

Hi,
The question is, can we only train the classification layer when do transfer learning of a pre-trained network? I want to speed up my training by keeping the feature extraction layers (base model) as they are and only replace and retrain the classification layers.
The equivalent way in Keras (Python) is by: base_model.trainable = False
If possible in Matlab, please let me know how. Your help is appreciated.
Cheers
Sud

Best Answer

In order to freeze the weights of a particular layer of your network set the properties WeightLearnRateFactor & BiasLearnRateFactor to zero. Refer to fullyconnectedLayer - Learn Rate and Regularization, convolution2dLayer - Learn Rate and Regularization & lstmLayer - Learn Rate and Regularization.
layer.WeightLearnRateFactor = 0;