Why does the number of channels (C) become 1 in the output of the 1D convolutional layer for SCBT data?
Show older comments
I have a SCBT dataset with dimensions of 100×49×1×1500, and I set up a 1D convolutional layer as:convolution1dLayer(3, 1, "Stride", 1). Why does the output data become 100×1×1×1500? How did the dimensions of the output data change to this result?
Answers (1)
Hitesh
on 10 Jun 2025
1 vote
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.
4 Comments
家俊
on 11 Jun 2025
家俊
on 11 Jun 2025
Hitesh
on 11 Jun 2025
Hi 家俊,
MATLAB uses this dimension order for 1D data in Deep Learning Toolbox:[H × W × C × N] = [Height × Width × Channels × Batch Size]
- 49 is the "time" or "sequence" length → this is what convolution1dLayer slides over
- 1 is the number of channels
- 100 is treated as "height" — meaning each of the 100 rows is convolved independently, like 100 separate 1D sequences per observation
- 1500 is batch size.
You want to convolve over the W = 49 dimension with filter size 3, stride 1, and produce 1 output channel.
layer = convolution1dLayer(3, 1, 'Stride', 1);
This will reduce the width from 49 to 47, using this formula:Output width=⌊49−31⌋+1=47
So the output shape will be: 100 × 47 × 1 × 1500
家俊
on 13 Jun 2025
Categories
Find more on Built-In Layers 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!