Error with averagePooling1dLayer (pooling dimension lower than pooling size)
Show older comments
Hello,
I am currently working on a sequence to label classification problem.
My dataset consists in 600 audio files. I have zero-padded them so that they all have the same length, i.e 62993 time-steps for each audio file.
My issue is that I do not manage to make my 1D CNN working when I try to use maxPooling1dLayer or avgPooling1dLayer.
My CNN is the following :
numFilters = 16;
filterSize = 3;
numClasses=2;
numFeatures=1;
layers = [ ...
sequenceInputLayer(numFeatures)
convolution1dLayer(filterSize,numFilters,Padding="causal")
reluLayer
layerNormalizationLayer
averagePooling1dLayer(2)
convolution1dLayer(filterSize,2*numFilters,Padding="causal")
reluLayer
layerNormalizationLayer
averagePooling1dLayer(2)
convolution1dLayer(filterSize,3*numFilters,Padding="causal")
reluLayer
layerNormalizationLayer
averagePooling1dLayer(2)
fullyConnectedLayer(64)
fullyConnectedLayer(numClasses)
softmaxLayer
classificationLayer];
Then I try to start the training using
miniBatchSize = 64;
max_epochs = 10; % Specify how long we should optimize
learning_rate = 10^(-3); % Try different learning rates
options = trainingOptions( 'adam',...
'MaxEpochs',max_epochs,...
'InitialLearnRate',learning_rate, ...
'Plots', 'training-progress', ...
'ValidationData', {test_audio,test_classes}, ...
'Shuffle','every-epoch', ...
'ValidationFrequency', 10, ...
'miniBatchSize', miniBatchSize,...
'ExecutionEnvironment','gpu', ...
SequencePaddingDirection="left");
net = trainNetwork(train_audio, train_classes, layers, options);
But I keep having this kind of errors (I do not have them when I remove the pooling layers) :
" Error in script_without_data_aug1DCNN (line 167)
net = trainNetwork(train_audio, train_classes, layers, options);
Caused by:
Layer 5: The size of the pooling dimension of the padded input data must be larger than or equal to the pool size. For networks with
sequence input, this check depends on the MinLength property of the sequence input layer. To ensure that this check is accurate, set
MinLength to the shortest sequence length of your training data. "
And I do not know why it is not working as expected. It is supposed to pool along the time dimension so the pooling dimension (60k+) is much higher than the pool size (2)... So I think the issue is inside the sizes of my training variables or the number of features that maybe you can tell me what is wrong.
- I used numFeatures=1 since I only have audio samples, so one channel.
My files have the following size (I have 453 audio in my training dataset) :
- train_audio contains my training audio samples, it is 453x1 cell and each cell is a 1x62993 double
- train_classes contains my training labels, it is a 453x1 categorical
1 Comment
yanqi liu
on 10 Mar 2022
yes,sir,may be check the dimension through net structure,or may be upload some dataset sample to debug
Accepted Answer
More Answers (0)
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!