Borrar filtros
Borrar filtros

Modifying unetLayers-architecture for distance map regression

9 visualizaciones (últimos 30 días)
Hello!
I want to modify the unetLayers-architecture (with encoderDepth = 4 and numClasses = 2) in order to be able to perform image-to-image regression where the input is a grayscale image and the output is a distance map (in grayscale) of the binary mask of the segmented grayscale image. I've removed the final two layers in the architecture by stating:
lgraph = removeLayers(lgraph, 'Softmax-Layer');
lgraph = removeLayers(lgraph,'Segmentation-Layer');
and added a regressionLayer for getting the regression output according to:
lgraph = lgraph.addLayers(regressionLayer('name','regressionLayer'));
lgraph = lgraph.connectLayers('Final-ConvolutionLayer', 'regressionLayer');
However, my knowledge of the thought behind the final layers of the UNet-architecture is limited. The final convolutional layer outputs a 128x128x2 output (since my input size is 128x128 and the number of classes is stated as 2). How can I optimally modify this structure (and especially the final convolutional layer) for a regression problem? Would adding a fully connected layer be helpful?

Respuesta aceptada

Srivardhan Gadila
Srivardhan Gadila el 11 de Mzo. de 2020
In addition to above replace the 'Final-ConvolutionLayer' with new convolution2dLayer having filter size 1 and number of filters 1 as follows:
imageSize = [128 128 1];
numClasses = 2;
encoderDepth = 4;
lgraph = unetLayers(imageSize,numClasses,'EncoderDepth',encoderDepth);
lgraph = replaceLayer(lgraph,'Final-ConvolutionLayer',convolution2dLayer(1,1,'Name','Final-ConvolutionLayer'));
lgraph = replaceLayer(lgraph,'Segmentation-Layer',regressionLayer('name','regressionLayer'));
lgraph = removeLayers(lgraph, 'Softmax-Layer');
lgraph = lgraph.connectLayers('Final-ConvolutionLayer', 'regressionLayer');
analyzeNetwork(lgraph)
  1 comentario
Julius Å
Julius Å el 11 de Mzo. de 2020
I actually did this myself before your answer and it worked out very well.
Thank you for answering anyways!

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by