trw.utils.batch_pad_minmax
¶
Module Contents¶
Functions¶
|
Add padding on a numpy array of samples. This works for an arbitrary number of dimensions |
|
Add padding on a numpy array of samples. This works for an arbitrary number of dimensions |
|
Add padding on a numpy array of samples. This works for an arbitrary number of dimensions |
|
Add padding on a list of numpy or tensor array of samples. Supports arbitrary number of dimensions |
- trw.utils.batch_pad_minmax.batch_pad_minmax_numpy(array: trw.basic_typing.NumpyTensorNCX, padding_min: trw.basic_typing.ShapeCX, padding_max: trw.basic_typing.ShapeCX, mode: str = 'edge', constant_value: trw.basic_typing.Numeric = 0) trw.basic_typing.NumpyTensorNCX ¶
Add padding on a numpy array of samples. This works for an arbitrary number of dimensions
- Parameters
array – a numpy array. Samples are stored in the first dimension
padding_min – a sequence of size len(array.shape)-1 indicating the width of the padding to be added at the beginning of each dimension (except for dimension 0)
padding_max – a sequence of size len(array.shape)-1 indicating the width of the padding to be added at the end of each dimension (except for dimension 0)
mode – numpy.pad mode
constant_value – constant used if mode == constant
- Returns
a padded array
- trw.utils.batch_pad_minmax.batch_pad_minmax_torch(array: trw.basic_typing.TorchTensorNCX, padding_min: trw.basic_typing.ShapeCX, padding_max: trw.basic_typing.ShapeCX, mode: str = 'edge', constant_value: trw.basic_typing.Numeric = 0) trw.basic_typing.TorchTensorNCX ¶
Add padding on a numpy array of samples. This works for an arbitrary number of dimensions
This function mimics the API of transform_batch_pad_numpy so they can be easily interchanged.
- Parameters
array – a Torch array. Samples are stored in the first dimension
padding_min – a sequence of size len(array.shape)-1 indicating the width of the padding to be added at the beginning of each dimension (except for dimension 0)
padding_max – a sequence of size len(array.shape)-1 indicating the width of the padding to be added at the end of each dimension (except for dimension 0)
mode – numpy.pad mode. Currently supported are (‘constant’, ‘edge’, ‘symmetric’)
constant_value – constant used if mode == constant
- Returns
a padded array
- trw.utils.batch_pad_minmax.batch_pad_minmax(array: trw.basic_typing.TensorNCX, padding_min: trw.basic_typing.ShapeCX, padding_max: trw.basic_typing.ShapeCX, mode: str = 'edge', constant_value: trw.basic_typing.Numeric = 0) trw.basic_typing.TensorNCX ¶
Add padding on a numpy array of samples. This works for an arbitrary number of dimensions
- Parameters
array – a numpy array. Samples are stored in the first dimension
padding_min – a sequence of size len(array.shape)-1 indicating the width of the padding to be added at the beginning of each dimension (except for dimension 0)
padding_max – a sequence of size len(array.shape)-1 indicating the width of the padding to be added at the end of each dimension (except for dimension 0)
mode – numpy.pad mode
constant_value – constant used if mode == constant
- Returns
a padded array
- trw.utils.batch_pad_minmax.batch_pad_minmax_joint(arrays: List[trw.basic_typing.TensorNCX], padding_min: trw.basic_typing.ShapeCX, padding_max: trw.basic_typing.ShapeCX, mode: str = 'edge', constant_value: trw.basic_typing.Numeric = 0) List[trw.basic_typing.TensorNCX] ¶
Add padding on a list of numpy or tensor array of samples. Supports arbitrary number of dimensions
- Parameters
arrays – a numpy array. Samples are stored in the first dimension
padding_min – a sequence of size len(array.shape)-1 indicating the width of the padding to be added at the beginning of each dimension (except for dimension 0)
padding_max – a sequence of size len(array.shape)-1 indicating the width of the padding to be added at the end of each dimension (except for dimension 0)
mode – numpy.pad mode
constant_value – constant used if mode == constant
- Returns
a list of padded arrays