Clear Filters
Clear Filters

trainNetwork error Size of Matrix Training Data for CNN Regression

2 views (last 30 days)
Description: I wanna transfer a DnCnn Training network to denoise a new 2-D data But it always send Error: X and Y must have the same number of observations. I only use 1 data to train and reshape the data as a formal dataset but it still did not work Very Need you help
Code: %Load Data load('Synmodule.mat'); load('SynNoise.mat');
Ximds=TraceDataNorm(s,0,1); Yimds = TraceDataNorm(SynNoise,0,1)-Ximds;
%Load Pretrained Network
XNew = zeros(size(Ximds,1),size(Ximds,2),1,1); XNew(:,:,1,1) = Ximds(:,:);
YNew = zeros(size(Yimds,1),size(Yimds,2),1,1); YNew(:,:,1,1) = Yimds(:,:);
net = denoisingNetwork('dncnn'); layers = dnCNNLayers();
%Train Network maxEpochs = 30; initLearningRate = 0.1; l2reg = 0.0001; batchSize = 128;
options = trainingOptions('sgdm',... 'Momentum',0.9,... 'InitialLearnRate',initLearningRate,... 'LearnRateSchedule','piecewise',... 'L2Regularization',l2reg,... 'MiniBatchSize',batchSize,... 'MaxEpochs',maxEpochs,... 'Plots','training-progress');
netTransfer = trainNetwork(XNew,Yimds,layers,options);
Error: nnet.internal.cnn.util.NetworkDataValidator/assertXAndYHaveSameNumberOfObservations (line 142) Invalid training data. X and Y must have the same number of observations.

Answers (0)

Categories

Find more on Statistics and Machine Learning Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!