Transpose#
- class deeptrack.features.Transpose(axes: tuple[int, ...] | None = None, **kwargs: Any)#
Bases:
FeatureTranspose the input array or tensor.
This feature rearranges the axes of an input array or tensor according to the specified order. The axes parameter determines the new order of the dimensions.
Parameters#
- axes: tuple[int, …], optional
A tuple specifying the permutation of the axes. If None (default), the axes are reversed.
- **kwargs: Any
Additional keyword arguments passed to the parent Feature class.
Methods#
- get(inputs, axes, **kwargs) -> array or tensor
Transpose the axes of the input array(s) or tensor(s). The inputs and outputs can be NumPy arrays or PyTorch tensors.
Examples#
>>> import deeptrack as dt
Create an input array:
>>> import numpy as np >>> >>> input_array = np.random.rand(2, 3, 4) >>> input_array.shape (2, 3, 4)
Apply a Transpose feature:
>>> transpose_feature = dt.Transpose(axes=(1, 2, 0)) >>> output_array = transpose_feature(input_array) >>> output_array.shape (3, 4, 2)
Without specifying axes:
>>> transpose_feature = dt.Transpose() >>> output_array = transpose_feature(input_array) >>> output_array.shape (4, 3, 2)
Methods Summary
get(inputs[, axes])Transpose the axes of the input array or tensor.
Methods Documentation
- get(inputs: ndarray | Tensor, axes: tuple[int, ...] | None = None, **kwargs: Any) ndarray | Tensor#
Transpose the axes of the input array or tensor.
Parameters#
- inputs: array or tenor
The input array or tensor to process. The input can be a NumPy array or a PyTorch tensor.
- axes: tuple[int, …], optional
A tuple specifying the permutation of the axes. If None (default), the axes are reversed.
- **kwargs: Any
Additional keyword arguments (unused here).
Returns#
- array or tensor
The transposed image with rearranged axes. The output can be a NumPy array or a PyTorch tensor.