torchoutil.extras.numpy.functional module¶
- is_numpy_number_like(
- x: Any,
Returns True if x is an instance of a numpy number type, a np.bool_ or a zero-dimensional numpy array. If numpy is not installed, this function always returns False.
- is_numpy_scalar_like(
- x: Any,
Returns True if x is an instance of a numpy number type or a zero-dimensional numpy array. If numpy is not installed, this function always returns False.
- numpy_complex_dtype_to_float_dtype(
- dtype: dtype,
Returns the associated float dtype from complex dtype. If input dtype is not complex, it just returns the same dtype.
- numpy_to_tensor(
- x: ndarray | number,
- *,
- device: device | None | Literal['default', 'cuda_if_available'] | str | int = None,
- dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
Convert numpy array to PyTorch tensor.
- numpy_view_as_complex(
- x: ndarray,
Convert complex array to float array.
- Args:
x: The input float array of any shape (…, 2)
- Returns:
x_real: The same data in a complex array of shape (…,)
- numpy_view_as_real(
- x: ndarray,
Convert complex array to float array.
- Args:
x: The input complex array of any shape (…,)
- Returns:
x_real: The same data in a float array of shape (…, 2)