How to train CNN with an image in the input and an image in the output?

Technical Source
2 min readMay 18, 2021

--

I have a task to train CNN with an image as input and an image as output. I have tried to do it at the beginning with Matlab tutorial, but matlab has no image as output, but a vector.

https://de.mathworks.com/help/deeplearning/examples/train-a-convolutional-neural-network-for-regression.html

any idea how i can do this tutorial again but with image as output?

For example you could insert input as image for number one and the output is also for number one but rotated or deformed.

ANSWER

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

I was also struggling with having an image as an output and I found the solution. Skip the fullyConnectedLayer(n) part, because it causes the network to have an output of either a vector or just a number. However, make sure not to include any Pooling layers if you want your output to be of the same size as your input, because they cause downsampling. Finally, keep in mind that the number of filters of your final conv network is the same number as the 3rd dimension of your output image. For example,

convolution2dLayer(3,1,’Padding’,’same’) gives an output image of (M,N,1), where M,N are the rows and columns of the initial image. The next code runs to me.

layers = [
imageInputLayer([64 64 1]) % My initial image is 64x64
convolution2dLayer(3,8,'Padding','same')
batchNormalizationLayer
reluLayer

% averagePooling2dLayer(2,'Stride',1) % Don't want this
convolution2dLayer(3,16,'Padding','same')
batchNormalizationLayer
reluLayer

SEE COMPLETE ANSWER CLICK THE LINK

--

--

Technical Source
Technical Source

Written by Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.

No responses yet