Problem with using convolutional Autoencoder
3 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I am using convolutional autoencoder to reconstruct fingerprint images how ever i am recieveing error
This is the code i am using
close all;
clc;
%% Initalize the data
dataDir= fullfile('Data/');
exts = {'.jpg','.png','.tif','BMP'};
imds = imageDatastore(fullfile(dataDir),...
'IncludeSubfolders',true,'FileExtensions','.jpg','LabelSource','foldernames');
countEachLabel(imds);
[TrainData, TestData] = splitEachLabel(imds, 0.5);
size(TrainData);
countEachLabel(TrainData);
numImages = numel(TrainData.Files);
for i = 1:numImages
img = readimage(TrainData, i);
img=rgb2gray(img);
img3= im2double(img);
scale = 0.5;
img8 = imresize(img3,scale);
img4= imshow(img8, 'InitialMagnification',800);
drawnow;
Train{i} = (img8); %#ok<SAGROW>
end
layers = [
imageInputLayer([28 28 3],"Name","imageinput","Normalization","none")
convolution2dLayer([3 3],64,"Name","conv_1","Padding","same")
leakyReluLayer(0.01,"Name","leakyrelu_1")
convolution2dLayer([3 3],128,"Name","conv_2","Padding","same")
leakyReluLayer(0.01,"Name","leakyrelu_3")
convolution2dLayer([3 3],128,"Name","conv_3","Padding","same")
leakyReluLayer(0.01,"Name","leakyrelu_4")
convolution2dLayer([3 3],64,"Name","conv_4","Padding","same")
batchNormalizationLayer("Name","batchnorm")
reluLayer("Name","relu1")
dropoutLayer(0.5,"Name","drop")
convolution2dLayer([3 3],1,"Name","conv_5","Padding","same")
leakyReluLayer(0.01,"Name","leakyrelu_5")
regressionLayer("Name","regressionoutput")];
autoenc = trainAutoencoder(Train,layers,'MaxEpochs',400,...
'DecoderTransferFunction','purelin','EncoderTransferFunction','satlin','L2WeightRegularization',0.004,'SparsityRegularization',4,'SparsityProportion',0.15);
numImages = numel(TestData.Files);
for i = 1:numImages
img5 = readimage(TestData, i);
img5=rgb2gray(img5);
img6= im2double(img5);
scale = 0.5;
img9 = imresize(img6,scale);
img7= imshow(img9, 'InitialMagnification', 800);
drawnow;
Test{i} = (img9); %#ok<SAGROW>
end
xReconstructed = predict(autoenc,Test);
%% Test Images
figure();
for i = 1:16
subplot(4,5,i);
imshow(TestData.Files{i});
end
%% Reconstructed images from TestData
figure();
for i = 1:16
subplot(4,5,i);
reconstructed = xReconstructed{i};
reconstructed(imbinarize(reconstructed)) = 1;
imshow(reconstructed)
end
This is the error
Error using Autoencoder.parseInputArguments (line 485)
'HiddenSize' must be an integer greater than 0.
Error in trainAutoencoder (line 107)
paramsStruct = Autoencoder.parseInputArguments(varargin{:});
Error in data_process1 (line 45)
autoenc = trainAutoencoder(Train,layers,'MaxEpochs',400,...
Kindly looking for your su[port
Best
0 件のコメント
回答 (1 件)
Madhav Thakker
2021 年 3 月 15 日
Hi Abdussalam,
The trainAutoencoder function expects the second argument as hiddenSize and not layers and create a sparse autoencoder.
I understand you want to create a convolutional auto-encoder. You can do so by using trainNetwork function and using layers to train a convolutional auto-encoder.
Hope this helps.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Image Data Workflows についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!