Skip to content

[Docs] Clarify cross_entropy inputs and use_softmax in Chinese API reference - #7934

Open
Daiyuanranfeng wants to merge 1 commit into
PaddlePaddle:developfrom
Daiyuanranfeng:docs/clarify-cross-entropy-input
Open

Daiyuanranfeng wants to merge 1 commit into
PaddlePaddle:developfrom
Daiyuanranfeng:docs/clarify-cross-entropy-input

Conversation

@Daiyuanranfeng

Copy link
Copy Markdown

PR types

Others

PR changes

Docs

Description

Document use_softmax in the Chinese cross_entropy signature and align the parameter order with the existing Paddle implementation and English docstring. Clarify that the default takes raw logits and that precomputed class probabilities require use_softmax=False.

This addresses the input ambiguity discussed in #5873. The three-class example with logits [0.4, 0.6, 0.8] and target [0, 1, 0] gives a categorical loss of approximately 1.11190143 when softmax is applied once.

Validation

  • Compared the documented parameter order against the upstream Python function using ast.
  • Verified the numerical example with Python's standard library.
  • prek run --files docs/api/paddle/nn/functional/cross_entropy_cn.rst and git diff --check passed.

Signed-off-by: Ziqiang Zhang <daiyuanranfeng@openatom.club>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant