Why does the number of channels (C) become 1 in the output of the 1D convolutional layer for SCBT data?

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?

Réponses (1)

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 commentaires

Thank you for your answer.
I'm still a bit confused about how to ensure that MATLAB's convolution1Dlayer correctly operates along the first spatial dimension and produces an output of shape 100 × 47 × 1 × 1500. Below is my overall network architecture. Could you please provide guidance?
layers=[sequenceInputLayer(1,'MiniLength',1024);
stfLayer('Window',hanning(1024,'periodic'),'TransformMode','realimag');
functionLayer(@(X) X(1:100,1:2:end,:,:));
convolution1dLayer(100,1,"Stride",1)]
For additional clarification.the functionLayer' output format is "SCBT" dlarray, seems correct.
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=4931+1=47
So the output shape will be: 100 × 47 × 1 × 1500
Actually, “layer = convolution1dLayer(3, 1, 'Stride', 1)”,the output shape is not100x47x1x1500. As you see, I haven't added averagePooling1dLayer(47) in my net, but the output result is indeed 100x1x1x1500.This is where I get confused.
Do you mean I have to change the channel order of the input format "SCBT" for the convolution1D layer?
Thank you for your generous help.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Deep Learning Toolbox dans Centre d'aide et File Exchange

Produits

Version

R2024b

Question posée :

le 9 Juin 2025

Commenté :

le 13 Juin 2025

Community Treasure Hunt

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

Start Hunting!

Translated by