torchoutil.nn.modules.numpy module

class NumpyToTensor(
*,
device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
)[source]

Bases: EModule

For more information, see numpy_to_tensor().

forward(
x: ndarray,
) 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 TensorToNumpy(
*,
dtype: str | dtype | None = None,
force: bool = False,
)[source]

Bases: EModule

For more information, see tensor_to_numpy().

forward(
x: Tensor,
) ndarray[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 ToNumpy(
*,
dtype: str | dtype | None = None,
force: bool = False,
)[source]

Bases: EModule

For more information, see to_numpy().

forward(
x: Tensor | ndarray | list,
) ndarray[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.