espnet2.svs.feats_extract.score_feats_extract.ListsToTensor
Less than 1 minute
espnet2.svs.feats_extract.score_feats_extract.ListsToTensor
espnet2.svs.feats_extract.score_feats_extract.ListsToTensor(xs)
Convert a list of lists into a list of equal length by padding.
This function takes a list of lists (each potentially of different lengths) and returns a new list where each inner list is padded with zeros to the length of the longest list. This is useful for preparing data for batch processing, where inputs must be of the same shape.
- Parameters:xs (list of list of int) – A list containing lists of integers, where each inner list represents a sequence of values.
- Returns: A list of lists where each inner list has been : padded with zeros to match the length of the longest list.
- Return type: list of list of int
Examples
>>> ListsToTensor([[1, 2], [3, 4, 5], [6]])
[[1, 2, 0], [3, 4, 5], [6, 0, 0]]
>>> ListsToTensor([[1], [2, 3]])
[[1, 0], [2, 3]]