torchwrench.nn.functional.others module¶
-
torchwrench.nn.functional.others.average_power(x: T_TensorOrArray, dim: int | tuple[int, ...] | None =
-1) T_TensorOrArray[source]¶ Compute average power of a signal along a specified dim/axis.
-
torchwrench.nn.functional.others.cat(tensors: list[Tensor] | tuple[Tensor, ...], dim: int =
0, *, out: Tensor | None =None) Tensor[source]¶
-
torchwrench.nn.functional.others.concat(tensors: list[Tensor] | tuple[Tensor, ...], dim: int =
0, *, out: Tensor | None =None) Tensor[source]¶
-
torchwrench.nn.functional.others.count_parameters(model: Module, *, recurse: bool =
True, only_trainable: bool =False, buffers: bool =False) int[source]¶ Returns the number of parameters in a module.
- torchwrench.nn.functional.others.deep_equal(x: T, y: T, *args: T) bool[source]¶
Recursive comparison between objects.
Supports Scalar-like, NDArrays, Tensors, DataFrames, Mapping and List-like objects. Unlike default equal, NaNs values are considered equal. Tensors and NDArrays of different shapes are supported and returns False.
-
torchwrench.nn.functional.others.find(value: Any, x: Tensor, *, default: None | Tensor | bool | int | float | complex =
None, dim: int =-1) LongTensor[source]¶ Return the index of the first occurrence of value in a tensor.
-
torchwrench.nn.functional.others.get_ndim(x: bool | int | float | complex | None | str | bytes | ndarray | generic | Tensor0D | Tensor | Iterable, *, use_first_for_list_tuple: bool =
False, return_indicator: False =False, return_default_on_invalid: False =False, default: Any =-1, return_valid: bool | None =None) int[source]¶ -
torchwrench.nn.functional.others.get_ndim(x: bool | int | float | complex | None | str | bytes | ndarray | generic | Tensor0D | Tensor | Iterable, *, use_first_for_list_tuple: bool =
False, return_indicator: False =False, return_default_on_invalid: bool, default: U =-1, return_valid: bool | None =None) int | U -
torchwrench.nn.functional.others.get_ndim(x: bool | int | float | complex | None | str | bytes | ndarray | generic | Tensor0D | Tensor | Iterable, *, use_first_for_list_tuple: bool =
False, return_indicator: True, return_default_on_invalid: False =False, default: Any =-1, return_valid: bool | None =None) ndim[int] -
torchwrench.nn.functional.others.get_ndim(x: bool | int | float | complex | None | str | bytes | ndarray | generic | Tensor0D | Tensor | Iterable, *, use_first_for_list_tuple: bool =
False, return_indicator: True, return_default_on_invalid: bool, default: U =-1, return_valid: bool | None =None) ndim[int | U] Scan first argument to return its number of dimension(s). Works recursively with Tensors, numpy arrays and builtins types instances.
Note: Sets and dicts are considered as scalars with a ndim equal to 0.
- Args:
x: Input value to scan. use_first_for_list_tuple: If True, use first value to determine ndim for list and tuple argument. Otherwise it will scan each value in argument to determine its shape. defaults to False. return_indicator: If True, returns a tuple containing a boolean indicator if the data has an homogeneous ndim instead of raising a ValueError. defaults to False. return_default_on_invalid: If True and return_indicator=False, returns the default value instead of raising a ValueError. defaults to False. default: Value to return if input is a heterogeneous list/tuple. defaults to (). return_valid: Deprecated. Use return_indicator instead.
- Raises:
ValueError if input has an heterogeneous number of dimensions and return_valid=False. TypeError if input has an unsupported type.
-
torchwrench.nn.functional.others.get_shape(x: bool | int | float | complex | None | str | bytes | ndarray | generic | Tensor0D | Tensor | DataFrame | list | tuple | set | frozenset | dict, *, output_type: Callable[[tuple[int, ...]], T] =
identity, use_first_for_list_tuple: bool =False, return_indicator: False =False, return_default_on_invalid: False =False, default: Any =(), return_valid: bool | None =None) T[source]¶ -
torchwrench.nn.functional.others.get_shape(x: bool | int | float | complex | None | str | bytes | ndarray | generic | Tensor0D | Tensor | DataFrame | list | tuple | set | frozenset | dict, *, output_type: Callable[[tuple[int, ...]], T] =
identity, use_first_for_list_tuple: bool =False, return_indicator: False =False, return_default_on_invalid: bool, default: U =(), return_valid: bool | None =None) T | U -
torchwrench.nn.functional.others.get_shape(x: bool | int | float | complex | None | str | bytes | ndarray | generic | Tensor0D | Tensor | DataFrame | list | tuple | set | frozenset | dict, *, output_type: Callable[[tuple[int, ...]], T] =
identity, use_first_for_list_tuple: bool =False, return_indicator: True, return_default_on_invalid: False =False, default: Any =(), return_valid: bool | None =None) shape[T] -
torchwrench.nn.functional.others.get_shape(x: bool | int | float | complex | None | str | bytes | ndarray | generic | Tensor0D | Tensor | DataFrame | list | tuple | set | frozenset | dict, *, output_type: Callable[[tuple[int, ...]], T] =
identity, use_first_for_list_tuple: bool =False, return_indicator: True, return_default_on_invalid: bool, default: U =(), return_valid: bool | None =None) shape[T | U] Scan first argument to return its shape. Works recursively with Tensors, numpy arrays and builtins types instances.
Note: Sets and dicts are considered as scalars with a shape equal to ().
- Args:
x: Input value to scan. output_type: Output shape type. defaults to identity, which returns a tuple of ints. use_first_for_list_tuple: If True, use first value in sequences to determine shape for list and tuple argument. Otherwise it will scan each value in argument to determine its shape. defaults to False. return_indicator: If True, returns a tuple containing a boolean indicator if the data has an homogeneous shape instead of raising a ValueError. defaults to False. return_default_on_invalid: If True and return_indicator=False, returns the default value instead of raising a ValueError. defaults to False. default: Value to return if input is a heterogeneous list/tuple. This default value is NOT passed to the output_type() callable argument. defaults to (). return_valid: Deprecated. Use return_indicator instead.
- Raises:
ValueError: if input has an heterogeneous shape and return_valid=False. TypeError: if input has an unsupported type.
-
torchwrench.nn.functional.others.mse(x1: Tensor, x2: Tensor, *, dim: int | tuple[int, ...] | None =
None) Tensor[source]¶ Mean squared error function.
-
torchwrench.nn.functional.others.ndim(x: bool | int | float | complex | None | str | bytes | ndarray | generic | Tensor0D | Tensor | Iterable, *, use_first_for_list_tuple: bool =
False, return_indicator: bool =False, return_default_on_invalid: bool =False, default: U =-1, return_valid: bool | None =None) int | U | ndim[int | U][source]¶ Scan first argument to return its number of dimension(s). Works recursively with Tensors, numpy arrays and builtins types instances.
Note: Sets and dicts are considered as scalars with a ndim equal to 0.
- Args:
x: Input value to scan. use_first_for_list_tuple: If True, use first value to determine ndim for list and tuple argument. Otherwise it will scan each value in argument to determine its shape. defaults to False. return_indicator: If True, returns a tuple containing a boolean indicator if the data has an homogeneous ndim instead of raising a ValueError. defaults to False. return_default_on_invalid: If True and return_indicator=False, returns the default value instead of raising a ValueError. defaults to False. default: Value to return if input is a heterogeneous list/tuple. defaults to (). return_valid: Deprecated. Use return_indicator instead.
- Raises:
ValueError if input has an heterogeneous number of dimensions and return_valid=False. TypeError if input has an unsupported type.
- torchwrench.nn.functional.others.nelement(x: bool | int | float | complex | None | str | bytes | ndarray | generic | Tensor0D | Tensor | Iterable) int[source]¶
Returns the number of elements in Tensor-like object.
-
torchwrench.nn.functional.others.prod(x: T_TensorOrArray, *, dim: int | None =
None, start: Any =1) T_TensorOrArray[source]¶ -
torchwrench.nn.functional.others.prod(x: Iterable[T_BuiltinNumber], *, dim: Any =
None, start: T_BuiltinNumber =1) T_BuiltinNumber Returns the product of all elements in input.
-
torchwrench.nn.functional.others.ranks(x: Tensor, dim: int =
-1, descending: bool =False) LongTensor[source]¶ Get the ranks of each value in range [0, x.shape[dim][.
-
torchwrench.nn.functional.others.rmse(x1: Tensor, x2: Tensor, *, dim: int | tuple[int, ...] | None =
None) Tensor[source]¶ Root mean squared error function.
- torchwrench.nn.functional.others.shape(x: bool | int | float | complex | None | str | bytes | ~numpy.ndarray | ~numpy.generic | ~torchwrench.types.tensor_subclasses.Tensor0D | ~torch.Tensor | ~pandas.DataFrame | list | tuple | set | frozenset | dict, *, output_type: ~typing.Callable[[~typing.Tuple[int, ...]], __SPHINX_IMMATERIAL_TYPE_VAR__V_T] = <function identity>, use_first_for_list_tuple: bool = False, return_indicator: bool = False, return_default_on_invalid: bool = False, default: __SPHINX_IMMATERIAL_TYPE_VAR__V_U = (), return_valid: bool | None = None) T | U | shape[T | U][source]¶
Scan first argument to return its shape. Works recursively with Tensors, numpy arrays and builtins types instances.
Note: Sets and dicts are considered as scalars with a shape equal to ().
- Args:
x: Input value to scan. output_type: Output shape type. defaults to identity, which returns a tuple of ints. use_first_for_list_tuple: If True, use first value in sequences to determine shape for list and tuple argument. Otherwise it will scan each value in argument to determine its shape. defaults to False. return_indicator: If True, returns a tuple containing a boolean indicator if the data has an homogeneous shape instead of raising a ValueError. defaults to False. return_default_on_invalid: If True and return_indicator=False, returns the default value instead of raising a ValueError. defaults to False. default: Value to return if input is a heterogeneous list/tuple. This default value is NOT passed to the output_type() callable argument. defaults to (). return_valid: Deprecated. Use return_indicator instead.
- Raises:
ValueError: if input has an heterogeneous shape and return_valid=False. TypeError: if input has an unsupported type.
-
torchwrench.nn.functional.others.stack(tensors: list[Tensor0D] | tuple[Tensor0D, ...], dim: int =
0, *, out: Tensor1D | None =None) Tensor1D[source]¶ -
torchwrench.nn.functional.others.stack(tensors: list[Tensor1D] | tuple[Tensor1D, ...], dim: int =
0, *, out: Tensor2D | None =None) Tensor2D -
torchwrench.nn.functional.others.stack(tensors: list[Tensor2D] | tuple[Tensor2D, ...], dim: int =
0, *, out: Tensor3D | None =None) Tensor3D -
torchwrench.nn.functional.others.stack(tensors: list[Tensor] | tuple[Tensor, ...], dim: int =
0, *, out: Tensor | None =None) Tensor