torchoutil.nn.modules.multiclass module

class 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.

training: bool
class IndexToOnehot(
num_classes: int,
*,
padding_idx: int | None = None,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = torch.bool,
)[source]

Bases: EModule

For more information, see index_to_onehot().

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

training: bool
class NameToOnehot(
idx_to_name: Mapping[int, T_Name] | Sequence[T_Name],
*,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = torch.bool,
)[source]

Bases: Generic[T_Name], Module

For more information, see name_to_onehot().

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

training: bool
class OnehotToIndex(
dim: int = -1,
)[source]

Bases: EModule

For more information, see onehot_to_index().

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(
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 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]

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

training: bool
class ProbsToIndex(
dim: int = -1,
)[source]

Bases: EModule

For more information, see probs_to_index().

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(
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 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]

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

training: bool
class ProbsToOnehot(
*,
dim: int = -1,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = torch.bool,
)[source]

Bases: EModule

For more information, see probs_to_onehot().

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