Error with averagePooling1dLayer (pooling dimension lower than pooling size)

20 visualizaciones (últimos 30 días)
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 comentario
yanqi liu
yanqi liu el 10 de Mzo. de 2022
yes,sir,may be check the dimension through net structure,or may be upload some dataset sample to debug

Iniciar sesión para comentar.

Respuesta aceptada

Joss Knight
Joss Knight el 9 de Mzo. de 2022
The time dimension is variable so just because you happen to be passing a long sequence into the network doesn't mean you're not trying to build a network that can handle a sequence of length 1. Try setting a MinLength on your sequenceInputLayer as suggested by the error message.
  4 comentarios
tcoura
tcoura el 9 de Mzo. de 2022
Indeed the error seems to be when I want to input my filtered sequences to the fully connected layers. I added a globalAveragePooling1dLayer just before the fully connected layers and now it works. However if I understand well, the globalAveragePooling1dLayer will take the average on maybe thousands of samples and then give this scalar as input to the hidden layers. This is not really what I want to do. I want to give all my whole filtered sequences to my hidden layers.
I looked at sequenceFoldingLayer but this is not really what I am looking for.
Still, thanks for trying to help me.
Brian Hemmat
Brian Hemmat el 11 de Mzo. de 2022
Editada: Brian Hemmat el 11 de Mzo. de 2022
Why did you try to set MinLength=5 ? It seems from your description that MinLength=62993.
Which layer is your "hidden" layer?
If you run
analyzeNetwork(layers)
you'll see that by the time it gets to classification, you have many time steps. Do you want a classification per time step (I don't think this makes sense with audio data) or a classification per audio file? If you want a single classification per audio file, you will have to collapse the time dimension somehow. Why doesn't the sequenceFoldingLayer work for you?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Install Products en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by