How to retrain segnet?

1 view (last 30 days)
vipin xavior
vipin xavior on 28 Feb 2018
Edited: Purvaja on 18 Feb 2025
Hello there, i am trying to do an incremental training of segnet available in Matlab (train first on a small database and then use resultant net to train on larger data). This i am not able to do with segnet as resultant net is not trainable network format. Here is the code i used,
lgraph = segnetLayers(imageSize, numClasses, 4); net = trainNetwork(trainingData, lgraph, options); save seg_net net; % net = retrain(trainingData, net, options); %what to write in retrain?!

Answers (1)

Purvaja
Purvaja on 6 Feb 2025
Edited: Purvaja on 18 Feb 2025
I understand that you want to achieve incremental training of an already trainedsegnetLayers model and train it on a different dataset.
We can approach this by first saving, loading and then converting it to layers since net.Layers” object does not retain the connections between layers. So, we will construct lost connections using “lgraphfrom the saved network and then use it for incremental training.
You can follow the given procedures:
  • Create the SegNet layers
lgraph = segnetLayers(imageSize,numClasses,2);
  • Train the network
net = trainNetwork(ds, lgraph, options);
  • Save the trained network
save('segnet.mat', 'net');
  • Load the saved network in another file
load('segnet.mat', 'net');
  • Reconstruct the layer graph from the loaded network
lgraph = layerGraph(net);
  • Incrementally train the network
net = trainNetwork(ds, lgraph, incrementalOptions);
For more clarification, the following documentation links would be helpful:
  1. This link will give you information about “segnetLayers” function, https://www.mathworks.com/help/vision/ref/segnetlayers.html
  2. This link describes about “layerGraphthat will help in building lost connections, https://www.mathworks.com/help/deeplearning/ref/nnet.cnn.layergraph.html
Since MATLAB does not recommend using “LayerGraph andsegnetLayers” as they would be deprecated in the future, you can exploredlnetwork.
Hope this helps you!

Categories

Find more on Deep Learning Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!