torchoutil.nn.functional.others module¶
- average_power( ) T_TensorOrArray[source]¶
Compute average power of a signal along a specified dim/axis.
- find(
- value: Any,
- x: Tensor,
- *,
- default: None | Tensor | bool | int | float | complex = None,
- dim: int = -1,
Return the index of the first occurrence of value in a tensor.
- ndim(
- x: bool | int | float | complex | None | str | bytes | ndarray | generic | Tensor0D | Tensor | Iterable,
- *,
- return_valid: Literal[False] = False,
- ndim(
- x: bool | int | float | complex | None | str | bytes | ndarray | generic | Tensor0D | Tensor | Iterable,
- *,
- return_valid: Literal[True],
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 shape equal to 0.
- Args:
x: Input value to scan. return_valid: If True, returns a tuple containing a boolean indicator if the data has an homogeneous ndim instead of raising a ValueError. defaults to False. 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.
- Raises:
ValueError if input has an heterogeneous number of dimensions. TypeError if input has an unsupported type.
- nelement(
- x: bool | int | float | complex | None | str | bytes | ndarray | generic | Tensor0D | Tensor | Iterable,
Returns the number of elements in Tensor-like object.
- prod( ) T_TensorOrArray[source]¶
- prod( ) T_BuiltinNumber
Returns the product of all elements in input.
- ranks( ) LongTensor[source]¶
Get the ranks of each value in range [0, x.shape[dim][.
- shape(
- x: bool | int | float | complex | None | str | bytes | ndarray | generic | Tensor0D | Tensor | Iterable,
- *,
- output_type: Callable[[Tuple[int, ...]], T] = identity,
- return_valid: Literal[False] = False,
- shape(
- x: bool | int | float | complex | None | str | bytes | ndarray | generic | Tensor0D | Tensor | Iterable,
- *,
- output_type: Callable[[Tuple[int, ...]], T] = identity,
- return_valid: Literal[True],
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. return_valid: If True, returns a tuple containing a boolean indicator if the data has an homogeneous shape instead of raising a ValueError. defaults to False. 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.
- Raises:
ValueError: if input has an heterogeneous shape. TypeError: if input has an unsupported type.