How to retrain segnet?
Show older comments
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)
I understand that you want to achieve incremental training of an already trained “segnetLayers” 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 “lgraph” from 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:
- This link will give you information about “segnetLayers” function, https://www.mathworks.com/help/vision/ref/segnetlayers.html
- This link describes about “layerGraph” that will help in building lost connections, https://www.mathworks.com/help/deeplearning/ref/nnet.cnn.layergraph.html
Since MATLAB does not recommend using “LayerGraph” and “segnetLayers” as they would be deprecated in the future, you can explore “dlnetwork”.
Hope this helps you!
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!