Skip to content

Commit

Permalink
Simplify transformer.rst code block
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeyuChen authored Jun 28, 2021
1 parent af678fb commit ccd3557
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions docs/model_zoo/transformers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ PaddleNLP Transformer API在提丰富预训练模型的同时,也降低了用
from paddlenlp.datasets import load_dataset
from paddlenlp.transformers import BertForSequenceClassification, BertTokenizer
train_ds, dev_ds, test_ds = load_dataset("chnsenticorp", splits=["train", "dev", "test"])
train_ds = load_dataset("chnsenticorp", splits=["train"])
model = BertForSequenceClassification.from_pretrained("bert-wwm-chinese", num_classes=len(train_ds.label_list))
Expand All @@ -400,7 +400,6 @@ PaddleNLP Transformer API在提丰富预训练模型的同时,也降低了用
for input_ids, token_type_ids, labels in train_data_loader():
logits = model(input_ids, token_type_ids)
loss = criterion(logits, labels)
probs = paddle.nn.functional.softmax(logits, axis=1)
loss.backward()
optimizer.step()
optimizer.clear_grad()
Expand Down

0 comments on commit ccd3557

Please sign in to comment.