Hi 家俊,
convolution1dLayer(3, 1, "Stride", 1) creates a 1D convolutional layer with
- Filter size = 3
- Number of filters (output channels) = 1
- Stride = 1
This means:
- The convolution slides over the sequence dimension (length 49) with a window of 3, step size 1.
- The output will have only 1 channel.
Input: 100 × 49 × 1 × 1500
Layer: convolution1dLayer(3, 1, "Stride", 1)
MATLAB expects 1D convolutions to apply over the first spatial dimension, not the second one. The convolution is applied over the second dimension (W = 49).Output width is calculated as:
Output width = ⌊Input width−Filter sizeStride⌋+1=47,so output shape becomes: 100 × 47 × 1 × 1500, but output needs to be 100 × 1 × 1 × 1500.
This means that globalAveragePooling1dLayer or averagePooling1dLayer(47) has been applied which reduces the width from 47 to 1. The reason the number of channels becomes 1 is because you set the number of filters in convolution1dLayer to 1:
- This sets the output channels to 1.
- The reduction in spatial dimensions (from 49 to 1) is due to a pooling or flattening operation after the convolution.