Error in running 1d cnn

1 view (last 30 days)
TRISHITA BANERJEE
TRISHITA BANERJEE on 15 May 2019
Answered: Shengjie Ren on 13 Jun 2020
% Train Basic 1D-CNN %
% Prepare XTrain,YTrain (signal,label)
%% TODO %%
XTrain = load('D:\Trishita\VAD_NN\voicedregion_signal');
YTrain= load('D:\Trishita\VAD_NN\voicedregion_label');
chunklength = 1000;
% numberofchunks = floor(length(XTrain)/chunklength);
numberofchunks = 1;
XTrain = reshape(XTrain(1:numberofchunks*chunklength),chunklength,1,numberofchunks);
YTrain = reshape(YTrain(1:numberofchunks*chunklength),chunklength,1,numberofchunks);
XValidation = load('D:\Trishita\VAD_NN\voicedregion_signal');
YValidation= load('D:\Trishita\VAD_NN\voicedregion_label');
chunklength = 1000;
% numberofchunks = floor(length(XValidation)/chunklength);
numberofchunks = 1;
XValidation = reshape(XValidation(1:numberofchunks*chunklength),chunklength,1,1,numberofchunks);
YValidation = reshape(YValidation(1:numberofchunks*chunklength),chunklength,1,1,numberofchunks);
% define network %
layers = [
% input signal chunk - 1000x1
imageInputLayer([1000 1 1])
convolution2dLayer([3,1],1,'Padding','same')
reluLayer
convolution2dLayer([3,1],32,'Padding','same')
reluLayer
convolution2dLayer([3,1],32,'Padding','same')
reluLayer
convolution2dLayer([3,1],32,'Padding','same')
reluLayer
fullyConnectedLayer(1000)
regressionLayer
];
% define training options
miniBatchSize = 128;
validationFrequency = 8000;
options = trainingOptions('sgdm', ...
'MiniBatchSize',miniBatchSize, ...
'MaxEpochs',30, ...
'InitialLearnRate',1e-3, ...
'LearnRateSchedule','piecewise', ...
'LearnRateDropFactor',0.1, ...
'LearnRateDropPeriod',20, ...
'Shuffle','every-epoch', ...
'ValidationData',{XValidation,YValidation}, ...
'ValidationFrequency',validationFrequency, ...
'Plots','training-progress', ...
'Verbose',false);
% train and wait
net = trainNetwork(XTrain,YTrain,layers,options);
My error is: XTrain =
reshape(XTrain(1:numberofchunks*chunklength),chunklength,1,numberofchunks);
>> BasicCNN
Index exceeds array bounds.

Answers (1)

Shengjie Ren
Shengjie Ren on 13 Jun 2020
Is the matlab program of 1D-CNN implemented? Is it easy to share? Thank you so much.1653482142@qq.com

Categories

Find more on Deep 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!