torchwrench.nn.modules.multiclass module

class torchwrench.nn.modules.multiclass.IndexToName(idx_to_name: Mapping[int, T_Name] | Sequence[T_Name])[source]

Bases: Generic[T_Name], Module

For more information, see index_to_name().

forward(index: list[int] | Tensor) list[T_Name][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.multiclass.IndexToOnehot(num_classes: int, *, padding_idx: int | None = None, device: device | None | 'default' | 'cuda_if_available' | str | int = None, dtype: dtype | None | 'default' | str | DTypeEnum = torch.bool)[source]

Bases: Module

For more information, see index_to_onehot().

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(index: list[int] | 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.multiclass.NameToIndex(idx_to_name: Mapping[int, T_Name] | Sequence[T_Name])[source]

Bases: Generic[T_Name], Module

For more information, see name_to_index().

forward(name: list[T_Name]) 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.multiclass.NameToOnehot(idx_to_name: Mapping[int, T_Name] | Sequence[T_Name], *, device: device | None | 'default' | 'cuda_if_available' | str | int = None, dtype: dtype | None | 'default' | str | DTypeEnum = torch.bool)[source]

Bases: Generic[T_Name], Module

For more information, see name_to_onehot().

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(name: list[T_Name]) 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.multiclass.OnehotToIndex(dim: int = -1)[source]

Bases: Module

For more information, see onehot_to_index().

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(onehot: 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.multiclass.OnehotToName(idx_to_name: Mapping[int, T_Name] | Sequence[T_Name], dim: int = -1)[source]

Bases: Generic[T_Name], Module

For more information, see onehot_to_name().

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(onehot: Tensor) list[T_Name][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.multiclass.ProbsToIndex(dim: int = -1)[source]

Bases: Module

For more information, see probs_to_index().

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(probs: 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.multiclass.ProbsToName(idx_to_name: Mapping[int, T_Name] | Sequence[T_Name], dim: int = -1)[source]

Bases: Generic[T_Name], Module

For more information, see probs_to_name().

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(probs: Tensor) list[T_Name][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.multiclass.ProbsToOnehot(*, dim: int = -1, device: device | None | 'default' | 'cuda_if_available' | str | int = None, dtype: dtype | None | 'default' | str | DTypeEnum = torch.bool)[source]

Bases: Module

For more information, see probs_to_onehot().

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(probs: 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.