Skip to content

Commit 53dee58

Browse files
committed
fix code example
1 parent 976a2d7 commit 53dee58

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

python/paddle/nn/functional/loss.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,6 +1697,7 @@ def kl_div(input, label, reduction='mean', log_target=False, name=None):
16971697
[5, 20]
16981698
16991699
>>> # if label is in the log space, set log_target = True
1700+
>>> target = paddle.uniform(shape, min=0, max=10).astype('float32')
17001701
>>> log_target = paddle.log(target)
17011702
>>> pred_loss_1 = F.kl_div(x, target, reduction='none')
17021703
>>> pred_loss_2 = F.kl_div(x, log_target, reduction='none', log_target=True)

python/paddle/nn/layer/loss.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,6 +1105,7 @@ class KLDivLoss(Layer):
11051105
[5, 20]
11061106
11071107
>>> # if label is in the log space, set log_target = True
1108+
>>> target = paddle.uniform(shape, min=0, max=10).astype('float32')
11081109
>>> log_target = paddle.log(target)
11091110
>>> kldiv_criterion_1 = nn.KLDivLoss(reduction='none')
11101111
>>> kldiv_criterion_2 = nn.KLDivLoss(reduction='none', log_target=True)

0 commit comments

Comments
 (0)