torchoutil.nn.functional.predicate module

all_eq(
x: Tensor | ndarray | bool | int | float | complex | None | str | bytes | generic | Tensor0D | Iterable,
dim: None = None,
) bool[source]
all_eq(
x: T_TensorOrArray,
dim: int,
) T_TensorOrArray

Check if all elements are equal in a tensor, ndarray, iterable or scalar object.

all_ne(
x: Tensor | ndarray | bool | int | float | complex | None | str | bytes | generic | Tensor0D | Iterable,
) bool[source]

Check if all elements are NOT equal in a tensor, ndarray, iterable or scalar object.

can_be_converted_to_tensor(
x: Any,
) bool[source]

Returns True if inputs can be passed to torch.as_tensor function.

This function returns False for heterogeneous inputs like [[], 1], but this kind of value can be accepted by torch.as_tensor.

can_be_stacked(
tensors: List[Any] | Tuple[Any, ...],
) typing_extensions.TypeGuard[List[Tensor] | Tuple[Tensor, ...]][source]

Returns True if inputs can be passed to torch.stack function, i.e. contains a list or tuple of tensors with the same shape.

is_complex(
x: Tensor,
) typing_extensions.TypeGuard[ComplexFloatingTensor][source]
is_complex(
x: ndarray,
) typing_extensions.TypeGuard[ndarray]
is_complex(
x: complex,
) typing_extensions.TypeGuard[complex]
is_complex(
x: Any,
) typing_extensions.TypeGuard[ComplexFloatingTensor | ndarray | complex]

Returns True if object is a/contains complex-valued object(s).

is_convertible_to_tensor(
x: Any,
) bool[source]

Returns True if inputs can be passed to torch.as_tensor function.

This function returns False for heterogeneous inputs like [[], 1], but this kind of value can be accepted by torch.as_tensor.

is_floating_point(
x: Tensor,
) typing_extensions.TypeGuard[FloatingTensor][source]
is_floating_point(
x: ndarray,
) typing_extensions.TypeGuard[ndarray]
is_floating_point(
x: float,
) typing_extensions.TypeGuard[float]
is_floating_point(
x: Any,
) typing_extensions.TypeGuard[FloatingTensor | ndarray | float]

Returns True if object is a/contains floating-point object(s).

is_full(
x: Tensor | ndarray,
target: Any = Ellipsis,
) bool[source]

Check if all element are equal to target in a tensor or array. Accept an optional value ‘target’ to specified the expected value.

is_sorted(
x: Tensor | ndarray | Iterable,
*,
reverse: bool = False,
strict: bool = False,
) bool[source]

Returns True if the sequence is sorted.

is_stackable(
tensors: List[Any] | Tuple[Any, ...],
) typing_extensions.TypeGuard[List[Tensor] | Tuple[Tensor, ...]][source]

Returns True if inputs can be passed to torch.stack function, i.e. contains a list or tuple of tensors with the same shape.

is_unique(
x: Tensor | ndarray | bool | int | float | complex | None | str | bytes | generic | Tensor0D | Iterable,
) bool[source]

Check if all elements are NOT equal in a tensor, ndarray, iterable or scalar object.