pyprobound.layers.layer.LengthManager

class LengthManager(*args, **kwargs)

Bases: Protocol

Protocol for output length and receptive field calculations.

__init__(*args, **kwargs)

Methods

in_len(length[, mode])

Calculates the receptive field.

out_len(length[, mode])

Calculates the number of elements in the output length dimension.

Attributes

in_channels

The number of input channels.

out_channels

The number of output channels.

Non-Inherited Members

property out_channels: int

The number of output channels.

property in_channels: int

The number of input channels.

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:

Optional[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.