Skip to content
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

Fix the bug that F.SoftmaxCrossEntropy does not work properly when ignore_label is other than -1 #2716

Merged
merged 5 commits into from
May 8, 2017

Conversation

delta2323
Copy link
Member

Fix #2715

@delta2323 delta2323 added the cat:bug Bug report or fix. label May 7, 2017
@okuta
Copy link
Member

okuta commented May 8, 2017

How about following code?

ret = cuda.reduce(
  'S t, raw T log_y, int32 n_channel, raw T coeff, S ignore_label', 'T out',
  't == ignore_label ? T(0) : log_y[_j * n_channel + t]',
  'a + b', 'out = a * -coeff[0]', '0', 'crossent_fwd'
)(t, log_y.reduced_view(), log_y.shape[-1], self._coeff, self.ignore_label)

@okuta okuta self-assigned this May 8, 2017
@delta2323
Copy link
Member Author

Thank you for suggestion. I would like to know the reason you prefer this implementation. I noticed that some kernels in this function are implemented in the way you suggested. Is the reason that we should align the implementation to existing ones?

@okuta
Copy link
Member

okuta commented May 8, 2017

Your code generates cubin for each self.ignore_label.

@delta2323
Copy link
Member Author

delta2323 commented May 8, 2017

Got it. Thank you. I will change as you suggest.

@delta2323
Copy link
Member Author

I fixed.

@okuta okuta added this to the v1.24.0 milestone May 8, 2017
@okuta
Copy link
Member

okuta commented May 8, 2017

LGTM!

@okuta okuta merged commit b8d683d into master May 8, 2017
@okuta okuta deleted the fix-sce-ignore-label branch May 8, 2017 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat:bug Bug report or fix.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants