nemo_automodel.training.utils
#
Module Contents#
Functions#
Counts the total number of padding token in the tail of labels |
API#
- nemo_automodel.training.utils.count_tail_padding(labels, ignore_label=-100)[source]#
Counts the total number of padding token in the tail of labels
e.g. labels = torch.tensor([ [-100, 1, 1, -100, -100], # 2 tail -100s [-100, -100, 2, 3, 4], # 0 tail -100s [5, 6, -100, -100, -100], # 3 tail -100s ]) count_tail_padding will return 5. Please do note thereโs more than 5 ignore labels.
- Parameters:
labels (torch.Tensor) โ the labels
ignore_label (int, optional) โ ignore label index. Defaults to -100.
- Returns:
total number of ignored tokens in the
labels
input.- Return type:
int