U-net looses connections, becomes linear rather than U-shaped (unetLayers)
Ältere Kommentare anzeigen
I'm trying to follow the example in Semantic Segmentation of Multispectral Images Using Deep Learning, with the goal of using the pretrained network for tranfer learning to my own semantic segmentation network to use on other terrain images. Unfortunately, my U-net becomes linear, and I cannot figure out why.
When training, the input image size is [256, 256, 6] and there are 18 classes. To keep things simple, I train my network with the data linked in the example and use the function unetLayers (rather than the helper function referenced in the example).
inputTileSize = [256,256,6];
lgraph = unetLayers(inputTileSize, 18, 'EncoderDepth', 4);
plot(lgraph)

I train the network using:
%the mat files and randomPatchExtractionDatastore function come from the
%linked matlab example page above
imds = imageDatastore("train_data.mat",FileExtensions=".mat",ReadFcn=@matRead6Channels);
pxds = pixelLabelDatastore("train_labels.png",classNames,pixelLabelIds);
dsTrain = randomPatchExtractionDatastore(imds,pxds,[256,256],PatchesPerImage=1000);
initialLearningRate = 0.05;
maxEpochs = 5; %low b/c proof of concept, not meant for actual use
minibatchSize = 8;
l2reg = 0.0001;
options = trainingOptions("sgdm",...
InitialLearnRate=initialLearningRate, ...
Momentum=0.9,...
L2Regularization=l2reg,...
MaxEpochs=maxEpochs,...
MiniBatchSize=minibatchSize,...
LearnRateSchedule="piecewise",...
Shuffle="every-epoch",...
GradientThresholdMethod="l2norm",...
GradientThreshold=0.05, ...
Plots="training-progress", ...
VerboseFrequency=20);
net = trainNetwork(dsTrain,lgraph,options);
save("my_multispectralUnet_2.mat", "net");
After training, I load and plot the network. It is linear, rather than U-shaped.
data = load("C:\\Work\\CMFD\\my_multispectralUnet_2.mat");
net = data.net;
plot(layerGraph(net.Layers))

No errors occur while running the above code. What happened to the connections between the encoder and decoder sections?
2 Kommentare
mohd akmal masud
am 14 Jun. 2023
you lost your connection between encoder and decorder network.
you can edit in network deisgner apps
Allison
am 14 Jun. 2023
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Semantic Segmentation finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!