torchoutil.nn.functional.others module

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.

cat(
tensors: List[T_Tensor] | Tuple[T_Tensor, ...],
dim: int = 0,
*,
out: T_Tensor | None = None,
) T_Tensor[source]
cat(
tensors: List[Tensor] | Tuple[Tensor, ...],
dim: int = 0,
*,
out: Tensor | None = None,
) Tensor
concat(
tensors: List[Tensor] | Tuple[Tensor, ...],
dim: int = 0,
*,
out: Tensor | None = None,
) Tensor[source]
count_parameters(
model: Module,
*,
recurse: bool = True,
only_trainable: bool = False,
buffers: bool = False,
) int[source]

Returns the number of parameters in a module.

deep_equal(
x: T,
y: T,
) bool[source]
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.

mse(
x1: Tensor,
x2: Tensor,
*,
dim: int | Tuple[int, ...] | None = None,
) Tensor[source]

Mean squared error function.

ndim(
x: bool | int | float | complex | None | str | bytes | ndarray | generic | Tensor0D | Tensor | Iterable,
*,
return_valid: Literal[False] = False,
) int[source]
ndim(
x: bool | int | float | complex | None | str | bytes | ndarray | generic | Tensor0D | Tensor | Iterable,
*,
return_valid: Literal[True],
) ndim

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,
) int[source]

Returns the number of elements in Tensor-like object.

prod(
x: T_TensorOrArray,
*,
dim: int | None = None,
start: Any = 1,
) T_TensorOrArray[source]
prod(
x: Iterable[T_BuiltinNumber],
*,
dim: Any = None,
start: T_BuiltinNumber = 1,
) T_BuiltinNumber

Returns the product of all elements in input.

ranks(
x: Tensor,
dim: int = -1,
descending: bool = False,
) LongTensor[source]

Get the ranks of each value in range [0, x.shape[dim][.

rmse(
x1: Tensor,
x2: Tensor,
*,
dim: int | Tuple[int, ...] | None = None,
) Tensor[source]

Root mean squared error function.

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,
) T[source]
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],
) shape[T]

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.

stack(
tensors: List[Tensor0D] | Tuple[Tensor0D, ...],
dim: int = 0,
*,
out: Tensor1D | None = None,
) Tensor1D[source]
stack(
tensors: List[Tensor1D] | Tuple[Tensor1D, ...],
dim: int = 0,
*,
out: Tensor2D | None = None,
) Tensor2D
stack(
tensors: List[Tensor2D] | Tuple[Tensor2D, ...],
dim: int = 0,
*,
out: Tensor3D | None = None,
) Tensor3D
stack(
tensors: List[Tensor] | Tuple[Tensor, ...],
dim: int = 0,
*,
out: Tensor | None = None,
) Tensor