Up-sampling in convolutional neural network

19 visualizaciones (últimos 30 días)
hoi
hoi el 26 de Dic. de 2018
Comentada: Ali Riza Durmaz el 15 de Abr. de 2019
Hi everyone,
for a project at university I am trying to rebuild a NN described in a paper. It was orininally designed in Keras (I don't have any code, only its rough describtion) and I'm struggling with one specific layer they're using. To up-sample their data, they use a layer which takes a single entry of its input and replicates it to a 2x2-region of the output. This results in a matrix with doubled dimensions, without zero-entries (assuming there was none in input) and same entry in each 2x2-block. It is an approximation to the inverse of the maxPooling-Layer of MATLAB. It is similar, but NOT the same as maxUnpooling-Layer, which keeps the position of an maximum-entry and fills up with zeros. For this specific "up-sampling-operation", there is no explicit NN-layer in MATLAB.
Does someone have an idea how I can do this operation?
An idea I had in mind: Just using the given maxUnpooling-Layer and hope there will be no big difference. I tried this and prepared my maxPooling-Layers with "HasUnpoolingOutputs", but it seems that maxUnpooling-Layer has to follow immediately after the maxPooling-Layer. I get unused outputs for my maxPooling-Layers and missing outputs for my maxUnpooling-Layers (seen via analyzeNetwork) as I use convolution-layers in between (see code for example).
layers = [
imageInputLayer([32 32 1])
convolution2dLayer(filterSize, 32, 'Padding', 'same')
batchNormalizationLayer()
reluLayer()
maxPooling2dLayer(2,'Stride',2,'HasUnpoolingOutputs',true) %
convolution2dLayer(filterSize, 64, 'Padding', 'same')
batchNormalizationLayer()
reluLayer()
maxUnpooling2dLayer() %
convolution2dLayer(filterSize, 32, 'Padding', 'same')
batchNormalizationLayer()
reluLayer()
fullyConnectedLayer(32)
regressionLayer
];
So in this case, one has to bring the outputs "indices" and "size" of the maxPooling-layer to the maxUnpooling-layer. But I don't know how this can be achieved :/
I'd be very thankful for any ideas.

Respuestas (1)

Teja Muppirala
Teja Muppirala el 27 de Dic. de 2018
I think you may be able to do it using a transposedConv2dLayer. This works, (though I'm not entirely confident that this is the most appropriate implementation). Define a new layer like this and then use it in your layers instead of the maxUnpooling.
upsample2x2Layer = transposedConv2dLayer(2,1,'Stride',2, 'WeightLearnRateFactor',0,'BiasLearnRateFactor',0);
upsample2x2Layer.Weights = [1 1;1 1];
upsample2x2Layer.Bias = [0];
We set the learn rate factors to zero so that the parameters in this layer are not changed during training.
  2 comentarios
hoi
hoi el 28 de Dic. de 2018
Editada: hoi el 29 de Dic. de 2018
Thanks a lot for your answer! Do I have to adjust the third dimension of weights and bias (which characterize my filter) to the actual number of channels (64 in this case)? I'm wondering because I get an 'Input size mismatch'.
Edit: I tried this. I get no more error, so input seems to be right, but the whole stack was reduced to a depth of 1, as the filter is applied to all depths at the same time and summed up to a single number.
Ali Riza Durmaz
Ali Riza Durmaz el 15 de Abr. de 2019
Hello Hoi,
I am dealing with a very similar problem currently. Did the approach of using transposedConv2dLayer with adjusted weight's, biases and their respective learn rate's set to zero solve the problem?
If I understand your last sentence right, you do need a way to apply this to all feature channel's separately so they won't be lost? If I understand the function correctly the second argument 'numFilters' specifies the number of output channels. So additionally to adjusting the weight, and biases you might need to adjust numFilters argument.
Best regards
Adidue

Iniciar sesión para comentar.

Categorías

Más información sobre Sequence and Numeric Feature Data Workflows en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by