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
Implement chainerx::SoftmaxCrossEntropy
and chainerx.softmax_cross_entropy
#8250
Implement chainerx::SoftmaxCrossEntropy
and chainerx.softmax_cross_entropy
#8250
Conversation
chainerx::SoftmaxCrossEntropy
and chainerx.softmax_cross_entropy
chainerx::SoftmaxCrossEntropy
and chainerx.softmax_cross_entropy
aa91516
to
6138818
Compare
3d569ab
to
baf3f98
Compare
@Hyv I've made this PR ready with updating PR description. Would you start reviewing? |
@@ -172,6 +172,42 @@ def forward_chainer(self, inputs): | |||
return out, | |||
|
|||
|
|||
@op_utils.op_test(['native:0']) |
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.
Can you also add 'cuda:0'
?
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.
Added!
@@ -100,7 +100,7 @@ def _is_chainerx_supported(self, input_arrays): | |||
return False | |||
if self.ignore_label != -1: | |||
return False | |||
if self.reduce != 'mean': | |||
if self.reduce == 'mean' and self.normalize: | |||
return False |
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.
These are the default configurations. How about instead of falling back, run the previous implementation in this case? The denominator https://github.com/chainer/chainer/pull/8250/files#diff-7f9fda8b243258115ef7bdac145fec8dL122 should be mask.sum()
instead of x.shape[0]
though.
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.
There was a bug with normalize
which I fixed in #8301. Maybe we should wait for that one to be merged before.
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.
Sounds good. I'll review #8301.
Resolved the conflict! |
Sorry one last suggestion #8250 (comment). |
Jenkins, test this please. |
LGTM! I'm thinking if we should introduce arguments after all similar to SCE in Chainer, simply to make it more useful. But this also applied to |
Jenkins CI test (for commit e330b1e, target branch master) succeeded! |
This PR implements
chainerx::SoftmaxCrossEntropy
andchainerx.softmax_cross_entropy
, as well as replacing its temporary implementations in Chainer inter-op and ChainerX MNIST example.Limitations:
x1
is two onlyignore_label
can not be specifiedcache_score
,class_weight
andenable_double_backprop
arguments thatF.softmax_cross_entropy
hasI fixed
F. SoftmaxCrossEntropy
'sforward_chainerx()
method to usechainerx.softmax_cross_entropy
as well.I will fix
chainer/chainerx_cc/examples/mnist/
andchainer/chainerx_cc/examples/mnist_py/
to use the new ChainerX implementation in another PR.