torchwrench.nn.modules.padding module

class torchwrench.nn.modules.padding.PadAndStackRec(pad_value: int | float | bool = 0, *, align: 'left' | 'right' | 'center' | 'random' = 'left', device: device | None | 'default' | 'cuda_if_available' | str | int = None, dtype: dtype | None | 'default' | str | DTypeEnum = None)[source]

Bases: Module

For more information, see pad_and_stack_rec().

extra_repr() str[source]

Return 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(sequence: Tensor | int | float | tuple | list) 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 Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class torchwrench.nn.modules.padding.PadDim(target_length: int, *, dim: int = -1, align: 'left' | 'right' | 'center' | 'random' = 'left', pad_value: int | float | bool | Tensor0D | Callable[[Tensor], int | float | bool] = 0.0, mode: 'constant' | 'reflect' | 'replicate' | 'circular' = 'constant', generator: Generator | None | 'default' | int = None)[source]

Bases: Module

For more information, see pad_dim().

extra_repr() str[source]

Return 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) 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 Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class torchwrench.nn.modules.padding.PadDims(target_lengths: Iterable[int], *, dims: Iterable[int] | None | 'auto' = None, aligns: 'left' | 'right' | 'center' | 'random' | Iterable['left' | 'right' | 'center' | 'random'] = 'left', pad_value: int | float | bool | Tensor0D | Callable[[Tensor], int | float | bool] = 0.0, mode: 'constant' | 'reflect' | 'replicate' | 'circular' = 'constant', generator: Generator | None | 'default' | int = None)[source]

Bases: Module

For more information, see pad_dims().

extra_repr() str[source]

Return 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) 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 Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.