You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/12/17 19:16:36 UTC
[GitHub] anirudhacharya commented on a change in pull request #13612: add
pos_weight for SigmoidBinaryCrossEntropyLoss
anirudhacharya commented on a change in pull request #13612: add pos_weight for SigmoidBinaryCrossEntropyLoss
URL: https://github.com/apache/incubator-mxnet/pull/13612#discussion_r242279400
##########
File path: python/mxnet/gluon/loss.py
##########
@@ -227,13 +238,20 @@ def __init__(self, from_sigmoid=False, weight=None, batch_axis=0, **kwargs):
super(SigmoidBinaryCrossEntropyLoss, self).__init__(weight, batch_axis, **kwargs)
self._from_sigmoid = from_sigmoid
- def hybrid_forward(self, F, pred, label, sample_weight=None):
+ def hybrid_forward(self, F, pred, label, sample_weight=None, pos_weight=None):
label = _reshape_like(F, label, pred)
if not self._from_sigmoid:
# We use the stable formula: max(x, 0) - x * z + log(1 + exp(-abs(x)))
- loss = F.relu(pred) - pred * label + F.Activation(-F.abs(pred), act_type='softrelu')
+ if pos_weight is None:
Review comment:
can default `pos_weight` be set to 1 since it is a multiplicative factor and update the formulas accordingly. Then we can do away with this `if else` statement.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services