Creating a convolutional neural network that outputs an image.

41 次查看(过去 30 天)
I am in the process of implementing a convolutional neural network for image denoising. The network architecture was proposed in THIS paper, on page 4. I am using Matlab 2018b, so I have all the latest Deep learning toolboxes installed. I have tried to recreate the neural network in the Deep Network Designer app, as can be seen in the two first images attached. The network analyzer shows no errors or warning, and the dimensions are ok.
Then I created an imagedatastore with my images. The second step was creating an denoisingImageDatastore for the sake of training deep networks. I then set the training options, and eventually went to train my network. All these steps were show in Mathworks tutorials, but here is the code anyway.
DatasetPath=fullfile('c:\', 'Users', 'Emir', 'Desktop', 'IU','seminarski', 'VOCdevkit', 'VOC2010','JPEGImagesSmall');
imds=imageDatastore(DatasetPath, 'IncludeSubfolders', true,...
'LabelSource','foldernames');
%% denoising image data set
dnimds=denoisingImageDatastore(imds,'patchSize', [64 64], 'PatchesPerImage', 64, 'ChannelFormat','grayscale');
%%
options = trainingOptions('sgdm', ...
'InitialLearnRate',0.01, ...
'MaxEpochs',1, ...
'Shuffle','every-epoch', ...
'ValidationFrequency',30, ...
'Verbose',false, ...
'Plots','training-progress',...
'ExecutionEnvironment', 'gpu');
%%
net=trainNetwork(dnimds, lgraph_8,options); %% lgraph_8 is the name of the network returned by the deep network designer app
I then went to test my trained network on the cameraman image.
I=imread('cameraman.tif');
noisyI=imnoise(I, 'gaussian', 0,0.01);
figure
imshowpair(I, noisyI, 'montage');
title('Original Image (left) and Noisy Image (right)')
%%
denoisedI=denoiseImage(noisyI,net);
figure
imshow(denoisedI)
title('Denoised Image')
I get the following error message when running this script.
"Name of layer output must be a character vector or string scalar.
Error in DAGNetwork/activations (line 815)
iValidateIsStringOrCharArray(layerOut);
Error in denoiseImage (line 73)
res = activations(net,inputImage,numLayers-1,'OutputAs','channels');
Error in Untitled (line 44)
denoisedI=denoiseImage(noisyI,net);"
What causes this error message? In the proposed network, the output is an image of the dimensions 64x64x1, however it seems that matlab only lets me use the classification and regression output layers. How do I overcome this. I analyzed the structure of this network, and it is quite similar to mine, but the code which gave me an error previously runs fine when I use that pretrained network. What changes can I make to my network so it doesn't give me these errors?

采纳的回答

Joss Knight
Joss Knight 2019-2-2
You have a DAGNetwork which means you cannot pass a layer index into activations, you have to pass a name:
res = activations(net,inputImage,net.Layers(numLayers-1).Name,'OutputAs','channels');
  4 个评论
Emir Semsic
Emir Semsic 2019-2-2
I've gotten around it by using the predict function for DAGNetworks, however the training process still gives an absurdly high RMSE. I've since turned to using the network architecture that the dnCNNLayers function returns, and I've gotten solid results with removing Gaussian noise from images. Now, I am trying to train it to remove Poisson type of noise, and I am having real trouble. Should I ask another question, or is it ok to try and resolve it in the comments?
Joss Knight
Joss Knight 2019-2-2
You should ask another question, because your question is now concerned with domain knowledge in Deep Learning and Computer Vision, rather than just MATLAB syntax, for which there are other, much more appropriate people to help!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with Deep Learning Toolbox 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by