"git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "4f403ea8994ee8785aa73957c827938e74cf0fe3"
Unverified Commit 72c6e8b8 authored by Xing Han Lu's avatar Xing Han Lu Committed by GitHub
Browse files

Update t5.rst (#14776)

parent a94105f9
...@@ -191,10 +191,8 @@ language modeling head on top of the decoder. ...@@ -191,10 +191,8 @@ language modeling head on top of the decoder.
labels = target_encoding.input_ids labels = target_encoding.input_ids
# replace padding token id's of the labels by -100 # 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) labels = torch.tensor(labels)
labels[labels == tokenizer.pad_token_id] = -100
# forward pass # forward pass
loss = model(input_ids=input_ids, attention_mask=attention_mask, labels=labels).loss loss = model(input_ids=input_ids, attention_mask=attention_mask, labels=labels).loss
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment