torchwrench.nn.modules.numpy module¶
-
class torchwrench.nn.modules.numpy.NDArrayToTensor(*, device: device | None | 'default' | 'cuda_if_available' | str | int =
None, dtype: dtype | None | 'default' | str | DTypeEnum =None)[source]¶ Bases:
ModuleFor more information, see
ndarray_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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
-
class torchwrench.nn.modules.numpy.TensorToNDArray(*, dtype: str | dtype | None =
None, force: bool =False)[source]¶ Bases:
ModuleFor more information, see
tensor_to_ndarray().- 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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
-
class torchwrench.nn.modules.numpy.ToNDArray(*, dtype: str | dtype | None =
None, force: bool =False)[source]¶ Bases:
ModuleFor more information, see
to_ndarray().- 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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.