tf.keras.layers.AdaptiveMaxPooling1D

Adaptive max pooling operation for 1D temporal or spatial data.

Inherits From: Layer, Operation

This layer applies an adaptive max pooling operation, which pools the input such that the output has a target length specified by output_size, regardless of the input length. The kernel size and stride are automatically computed to achieve the target output size.

output_size Integer specifying the target output length.
data_format string, either "channels_last" or "channels_first". "channels_last" corresponds to inputs with shape (batch, length, channels). "channels_first" corresponds to inputs with shape (batch, channels, length). Defaults to the value found in your Keras config file at ~/.keras/keras.json. If never set, "channels_last" is used.

  • If data_format="channels_last": 3D tensor (batch_size, length, channels)
  • If data_format="channels_first": 3D tensor (batch_size, channels, length)

  • If data_format="channels_last": (batch_size, output_length, channels)
  • If data_format="channels_first": (batch_size, channels, output_length)

>>> import numpy as np
>>> input_seq = np.random.rand(1, 64, 3)
>>> layer = AdaptiveMaxPooling1D(output_size=32)
>>> output_seq = layer(input_seq)
>>> output_seq.shape
(1, 32, 3)

input Retrieves the input tensor(s) of a symbolic operation.

Only returns the tensor(s) corresponding to the first time the operation was called.

output Retrieves the output tensor(s) of a layer.

Only returns the tensor(s) corresponding to the first time the operation was called.

Methods

from_config

View source

Creates an operation from its config.

This method is the reverse of get_config, capable of instantiating the same operation from the config dictionary.

if "dtype" in config and isinstance(config["dtype"], dict):
    policy = dtype_policies.deserialize(config["dtype"])

Args
config A Python dictionary, typically the output of get_config.

Returns
An operation instance.