max pooling operation for 1d temporal data downsamples the input representation by taking the maximum value over a spatial window of size poolsize the window is shifted by strides the resulting output when using the valid padding option has a shape of outputshape inputshape poolsize 1 strides the resulting output shape when using the same padding option is outputshape inputshape strides args poolsize int size of the max pooling window strides int or none specifies how much the pooling window moves for each pooling step if none it will default to poolsize padding string either valid or same caseinsensitive valid means no padding same results in padding evenly to the leftright or updown of the input such that output has the same heightwidth dimension as the input dataformat string either channelslast or channelsfirst the ordering of the dimensions in the inputs channelslast corresponds to inputs with shape batch steps features while channelsfirst corresponds to inputs with shape batch features steps it defaults to the imagedataformat value found in your keras config file at keraskeras json if you never set it then it will be channelslast input shape if dataformatchannelslast 3d tensor with shape batchsize steps features if dataformatchannelsfirst 3d tensor with shape batchsize features steps output shape if dataformatchannelslast 3d tensor with shape batchsize downsampledsteps features if dataformatchannelsfirst 3d tensor with shape batchsize features downsampledsteps examples strides1 and paddingvalid x np array1 2 3 4 5 x np reshapex 1 5 1 maxpool1d keras layers maxpooling1dpoolsize2 strides1 paddingvalid maxpool1dx strides2 and paddingvalid x np array1 2 3 4 5 x np reshapex 1 5 1 maxpool1d keras layers maxpooling1dpoolsize2 strides2 paddingvalid maxpool1dx strides1 and paddingsame x np array1 2 3 4 5 x np reshapex 1 5 1 maxpool1d keras layers maxpooling1dpoolsize2 strides1 paddingsame maxpool1dx max pooling operation for 1d temporal data downsamples the input representation by taking the maximum value over a spatial window of size pool_size the window is shifted by strides the resulting output when using the valid padding option has a shape of output_shape input_shape pool_size 1 strides the resulting output shape when using the same padding option is output_shape input_shape strides args pool_size int size of the max pooling window strides int or none specifies how much the pooling window moves for each pooling step if none it will default to pool_size padding string either valid or same case insensitive valid means no padding same results in padding evenly to the left right or up down of the input such that output has the same height width dimension as the input data_format string either channels_last or channels_first the ordering of the dimensions in the inputs channels_last corresponds to inputs with shape batch steps features while channels_first corresponds to inputs with shape batch features steps it defaults to the image_data_format value found in your keras config file at keras keras json if you never set it then it will be channels_last input shape if data_format channels_last 3d tensor with shape batch_size steps features if data_format channels_first 3d tensor with shape batch_size features steps output shape if data_format channels_last 3d tensor with shape batch_size downsampled_steps features if data_format channels_first 3d tensor with shape batch_size features downsampled_steps examples strides 1 and padding valid x np array 1 2 3 4 5 x np reshape x 1 5 1 max_pool_1d keras layers maxpooling1d pool_size 2 strides 1 padding valid max_pool_1d x strides 2 and padding valid x np array 1 2 3 4 5 x np reshape x 1 5 1 max_pool_1d keras layers maxpooling1d pool_size 2 strides 2 padding valid max_pool_1d x strides 1 and padding same x np array 1 2 3 4 5 x np reshape x 1 5 1 max_pool_1d keras layers maxpooling1d pool_size 2 strides 1 padding same max_pool_1d x
from keras.api_export import keras_export
from keras.layers.pooling.base_pooling import BasePooling


@keras_export(["keras.layers.MaxPooling1D", "keras.layers.MaxPool1D"])
class MaxPooling1D(BasePooling):
    

    def __init__(
        self,
        pool_size=2,
        strides=None,
        padding="valid",
        data_format=None,
        name=None,
        **kwargs
    ):
        super().__init__(
            pool_size,
            strides,
            pool_dimensions=1,
            pool_mode="max",
            padding=padding,
            data_format=data_format,
            name=name,
            **kwargs,
        )