Error using trainNetwork (line 184) Invalid network. Caused by: Layer 4: The size of the pooling dimension of the padded input data must be larger than or equal to the pool si
6 views (last 30 days)
I want to study the performance of a given network varying the size and number of filters in convolution1dLayer and the number of windows provided as input to the trainNetwork function itself.
As you can see from the picture, I already defined (in a way that is suitable for Matlab) x_train and y_train, respectively the input and the output to my network. It should indeed receive a sequence of data from 3 sensors (in the Workspace, variable defined by n_window) and 5783 time points (in the variable length). Also, if I wish to, I could give to the network an input sequence (x_train) as a 1x1 cell (as it already is in the picture) with even greater number of windows (repeated sequences of 3*5723 matrices in x_train). This obviously implies to change the y_train as well, and the code does it well enough. For completeness, I sat the following options: solver to 'adam', maxEpochs equal to 100, SequencePaddingDirection to left and Verbose to 0.
Nevertheless, I was about to run the algorithm (just once, and that explains the break in the inner loop), to check whether it was about to work or not, but I get the following error. I don't know what is wrong, because the inputSize, parameter of the sequenceInputLayer layer, is [3 5723]. Therefore, since I sat the pooling to 2 and a stride of 2, there should be no errors, at least theoretically. I also tried to change the stride to 1, but no change in the error occurred. What am I doing wrong? Thanks in advance for your help! :)
Also, I just tried to add a MinLength parameter in sequenceInputLayer, as suggested by the error message: setting it to either 1, n_features (equal to 3) or length (equal to 5723) doesn't change the final result.
Ben on 21 Jun 2022
The issue is that the 2nd layer convolution1dLayer(3,10) has no padding. Currently its input size is [3, 5723, ?] where 3 is n_features, 5723 is length and ? represents the sequence dimension that is variable.
For a sequenceInputLayer where the input size is a two dimensional vector like [n_features, length] we interpret the first dimension as space and the 2nd dimension as features/channels.
The convolution1dLayer(3,10) operates on just the space dimension here and it will "squash" that size to [1, 10, ?] which is too small for pooling window of size 2.
You can see this by calling analyzeNetwork(layers) and checking the Activations column.
You can set the "Padding" to make things run - for example convolution1dLayer(3,10,"Padding","same") - however I think you probably want to adjust some things as the 5723 appears to be sequence length, which you shouldn't need to specify in sequenceInputLayer's input size - you might use it in the "MinLength" name-value pair though.