%% Perform 1-D Maximum Pooling
% Create a formatted dlarray object containing a batch of 128 sequences of length 100 with 12 channels. Specify the format 'CBT' (channel, batch, time).

miniBatchSize = 128;
sequenceLength = 100;
numChannels = 12;
X = rand(numChannels,miniBatchSize,sequenceLength);
dlX = dlarray(X,'CBT');

% View the size and format of the input data.

size(dlX)
dims(dlX)

% Apply 1-D maximum pooling with pooling regions of size 2 with a stride of 2 using the maxpool function by specifying the 'PoolFormat' and 'Stride' options.

poolSize = 2;
dlY = maxpool(dlX,poolSize,'PoolFormat','T','Stride',2);

% View the size and format of the output.

size(dlY)
dims(dlY)

% Copyright 2020 The MathWorks, Inc.