torchoutil.nn.modules.transform module¶
- class AsTensor(
- *,
- device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
- dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
Bases:
EModuleModule version of
as_tensor().- 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: Any,
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 Flatten( )[source]¶
Bases:
EModule- 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,
- forward( ) ndarray
- forward(
- x: T_BuiltinScalar,
- forward(
- x: Iterable[T_BuiltinScalar],
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 Identity(
- *args,
- **kwargs,
Bases:
EModule- forward(
- x: T,
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 MoveToRec( )[source]¶
Bases:
EModuleModule version of
move_to_rec().- forward(
- x: Any,
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 PadAndCropDim(
- target_length: int,
- align: Literal['left', 'right', 'center', 'random'] = 'left',
- pad_value: int | float | bool | Callable[[Tensor], int | float | bool] = 0.0,
- dim: int = -1,
- mode: Literal['constant', 'reflect', 'replicate', 'circular'] = 'constant',
- generator: Generator | None | Literal['default'] | int = None,
Bases:
EModule- 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 RepeatInterleaveNd( )[source]¶
Bases:
EModuleFor more information, see
repeat_interleave_nd().- 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 ResampleNearestFreqs(orig_freq: int, new_freq: int, dims: int | ~typing.Iterable[int] = -1, round_fn: ~typing.Callable[[~torch.Tensor], ~torch.Tensor] = <built-in method floor of type object>)[source]¶
Bases:
EModule- 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 ResampleNearestRates(rates: float | ~typing.Iterable[float], dims: int | ~typing.Iterable[int] = -1, round_fn: ~typing.Callable[[~torch.Tensor], ~torch.Tensor] = <built-in method floor of type object>)[source]¶
Bases:
EModuleFor more information, see
resample_nearest_rates().- 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 ResampleNearestSteps(steps: float | ~typing.Iterable[float], dims: int | ~typing.Iterable[int] = -1, round_fn: ~typing.Callable[[~torch.Tensor], ~torch.Tensor] = <built-in method floor of type object>)[source]¶
Bases:
EModule- 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 Shuffled( )[source]¶
Bases:
EModule- 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 Squeeze(
- dim: None | int | Iterable[int] = None,
- mode: Literal['view_if_possible', 'view', 'copy', 'inplace'] = 'view_if_possible',
Bases:
EModuleModule version of
squeeze().- 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 ToItem(
- *,
- strict_load: bool = False,
- config_to_extra_repr: bool = False,
- device_detect_mode: Literal['proxy', 'first_param', 'none'] = 'first_param',
Bases:
EModuleModule version of
to_item().- forward(
- x: bool | int | float | complex | None | str | bytes | ndarray | generic | Tensor0D | Tensor | SupportsIterLen,
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 TopP(
- p: float,
- dim: int = -1,
- largest: bool = True,
- *,
- return_values: bool = True,
- return_indices: bool = True,
Bases:
EModuleModule version of
top_p().- 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 Topk(
- k: int,
- dim: int = -1,
- largest: bool = True,
- sorted: bool = True,
- *,
- return_values: bool = True,
- return_indices: bool = True,
Bases:
EModuleModule version of
topk().- 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 TransformDrop(
- transform: Callable[[T], T],
- p: float,
- generator: Generator | None | Literal['default'] | int = None,
Bases:
Generic[T],EModule[T,T]- 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: T,
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 Unsqueeze(
- dim: int | Iterable[int],
- mode: Literal['view_if_possible', 'view', 'copy', 'inplace'] = 'view_if_possible',
Bases:
EModuleModule version of
unsqueeze().- 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: T_TensorOrArray,
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 ViewAsComplex(
- *,
- strict_load: bool = False,
- config_to_extra_repr: bool = False,
- device_detect_mode: Literal['proxy', 'first_param', 'none'] = 'first_param',
Bases:
EModuleModule version of
to_item().- forward( ) ComplexFloatingTensor | ndarray | complex[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 ViewAsReal(
- *,
- strict_load: bool = False,
- config_to_extra_repr: bool = False,
- device_detect_mode: Literal['proxy', 'first_param', 'none'] = 'first_param',
Bases:
EModuleModule version of
to_item().- forward( ) Tensor | ndarray | Tuple[float, float][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.