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

1 Ansicht (letzte 30 Tage)
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?

Antworten (1)

Hitesh
Hitesh am 10 Jun. 2025
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 Kommentare
Hitesh
Hitesh am 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=4931+1=47
So the output shape will be: 100 × 47 × 1 × 1500
家俊
家俊 am 13 Jun. 2025
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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Image Data Workflows finden Sie in Help Center und File Exchange

Produkte


Version

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by