espnet2.enh.layers.conv_utils.num2tuple
Less than 1 minute
espnet2.enh.layers.conv_utils.num2tuple
espnet2.enh.layers.conv_utils.num2tuple(num)
Convert a number into a tuple of two identical numbers.
This utility function is useful for ensuring that a single integer input can be treated as a pair of values (e.g., for height and width in convolutional operations). If the input is already a tuple, it is returned unchanged.
- Parameters:num (int or tuple) – A number or a tuple of two numbers.
- Returns: A tuple containing two identical numbers if num is an integer; otherwise, the original tuple if num is already a tuple.
- Return type: tuple
Examples
>>> num2tuple(5)
(5, 5)
>>> num2tuple((3, 4))
(3, 4)
NOTE
This function is primarily intended for internal use in convolution-related calculations.