pyprobound.layers.maxpool.MaxPool1dSpec

class MaxPool1dSpec(in_channels, kernel_size, ceil_mode=True, name='')

Bases: LayerSpec

Specification passed to torch.nn.MaxPool1d.

__init__(in_channels, kernel_size, ceil_mode=True, name='')

Initializes the maxpooling specification.

Parameters:
  • in_channels (int) – The number of input channels.

  • kernel_size (int) – The size of the sliding window.

  • ceil_mode (bool) – Whether to use ceil instead of floor for the output shape.

  • name (str) – A string used to describe the maxpooling specification.

Methods

check_length_consistency()

Checks that input lengths of Binding components are consistent.

components()

Iterator of child components.

forward()

Define the computation performed at every call.

freeze()

Turns off gradient calculation for all parameters.

in_len(length[, mode])

Calculates the receptive field.

max_embedding_size()

The maximum number of bytes needed to encode a sequence.

optim_procedure([ancestry, current_order])

The sequential optimization procedure for all Binding components.

out_len(length[, mode])

Calculates the number of elements in the output length dimension.

reload(checkpoint)

Loads the model from a checkpoint file.

reload_from_state_dict(state_dict)

Loads the model from a state dict.

save(checkpoint[, flank_lengths])

Saves the model to a file with "state_dict" and "metadata" fields.

unfreeze([parameter])

Turns on gradient calculation for the specified parameter.

update_binding_optim(binding_optim)

Updates a BindingOptim with the specification's optimization steps.

Attributes

ceil_mode

Whether to use ceil instead of floor for the output shape.

in_channels

The number of input channels.

kernel_size

The size of the sliding window.

out_channels

The number of output channels.

unfreezable

alias of Literal['all']

Non-Inherited Members

property kernel_size: int

The size of the sliding window.

property ceil_mode: bool

Whether to use ceil instead of floor for the output shape.

out_len(length, mode='shape')

Calculates the number of elements in the output length dimension.

Parameters:
  • length (TypeVar(T, int, Tensor)) – The input length.

  • mode (Literal['min', 'max', 'shape']) – Either shape, which returns the number of elements, or min or max, which return the minimum or maximum number of finite elements.

Return type:

TypeVar(T, int, Tensor)

Returns:

The number of elements in the output length dimension, according to the specified mode.

in_len(length, mode='max')

Calculates the receptive field.

Parameters:
  • length (TypeVar(T, int, Tensor)) – The output length.

  • mode (Literal['min', 'max']) – Either min or max, representing the minimum or maximum number of positions contributing to the output length.

Return type:

TypeVar(T, int, Tensor)

Returns:

The number of input positions that contribute to the values of the corresponding number of output positions. Outputs None if the max receptive field is undefined.