New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve docs of softmax_cross_entropy #3105
Improve docs of softmax_cross_entropy #3105
Conversation
Jenkins, test this please |
@keisuke-umezawa Jenkins tests failed. Could you rebase it to the current master? |
9a53cb9
to
c0f376a
Compare
@mitmul I rebased this branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late review. LGTM except for the followings.
@@ -223,17 +223,21 @@ def backward_gpu(self, inputs, grad_outputs): | |||
def softmax_cross_entropy( | |||
x, t, normalize=True, cache_score=True, class_weight=None, | |||
ignore_label=-1, reduce='mean'): | |||
"""Computes cross entropy loss for pre-softmax activations. | |||
"""Computes cross entropy loss after softmax activations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that the previous sentence is better; in your sentence, it is a bit confusing that we should apply "softmax" functions before calling softmax_cross_entropy
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revereted it.
>>> log_softmax = -F.log_softmax(x) | ||
>>> expected_loss = np.mean([log_softmax[row, column].data \ | ||
for row, column in enumerate(t)]) | ||
>>> y.data == expected_loss |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about using y.array
instead of y.data
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. I used y.array
@rezoo I fixed them! |
Thank you. LGTM. |
This is PR for improving docs of functions/links. Related issue: #2182
Modified functions/links: