-
Notifications
You must be signed in to change notification settings - Fork 31.1k
Closed
Description
I noticed the following nested list comprehension being recommended in the T5 docs:
# replace padding token id's of the labels by -100
labels = [
[(label if label != tokenizer.pad_token_id else -100) for label in labels_example] for labels_example in labels
]
labels = torch.tensor(labels)I believe it's possible to simplify above to:
labels = torch.tensor(labels)
labels[labels == tokenizer.pad_token_id] = -100I would be happy to make a PR if the change is deemed relevant, though I'm not sure where the docs are located so please let me know if needed :)
Metadata
Metadata
Assignees
Labels
No labels