torchoutil.nn.modules.pad module¶
- class PadAndStackRec(
- pad_value: int | float | bool = 0,
- *,
- align: Literal['left', 'right', 'center', 'random'] = 'left',
- device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
- dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
Bases:
EModuleFor more information, see
pad_and_stack_rec().- extra_repr() str[source]¶
Set the extra representation of the module.
To print customized extra information, you should re-implement this method in your own modules. Both single-line and multi-line strings are acceptable.
- forward( ) Tensor[source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class PadDim(
- target_length: int,
- *,
- dim: int = -1,
- align: Literal['left', 'right', 'center', 'random'] = 'left',
- pad_value: int | float | bool | Callable[[Tensor], int | float | bool] = 0.0,
- mode: Literal['constant', 'reflect', 'replicate', 'circular'] = 'constant',
- generator: Generator | None | Literal['default'] | int = None,
Bases:
EModuleFor more information, see
pad_dim().- extra_repr() str[source]¶
Set the extra representation of the module.
To print customized extra information, you should re-implement this method in your own modules. Both single-line and multi-line strings are acceptable.
- forward(
- x: Tensor,
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class PadDims(
- target_lengths: Iterable[int],
- *,
- dims: Iterable[int] = (-1,),
- aligns: Iterable[Literal['left', 'right', 'center', 'random']] = ('left',),
- pad_value: int | float | bool | Callable[[Tensor], int | float | bool] = 0.0,
- mode: Literal['constant', 'reflect', 'replicate', 'circular'] = 'constant',
- generator: Generator | None | Literal['default'] | int = None,
Bases:
EModuleFor more information, see
pad_dims().- extra_repr() str[source]¶
Set the extra representation of the module.
To print customized extra information, you should re-implement this method in your own modules. Both single-line and multi-line strings are acceptable.
- forward(
- x: Tensor,
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.