hed_rnn.py 文件源码

python
阅读 39 收藏 0 点赞 0 评论 0

项目:merlin 作者: CSTR-Edinburgh 项目源码 文件源码
def multiclass_hinge_loss(self, predictions, targets, delta=1):
        num_cls = predictions.shape[1]
        if targets.ndim == predictions.ndim - 1:
            targets = T.extra_ops.to_one_hot(targets, num_cls)
        elif targets.ndim != predictions.ndim:
            raise TypeError('rank mismatch between targets and predictions')
        corrects = predictions[targets.nonzero()]
        rest = T.reshape(predictions[(1-targets).nonzero()],
                                 (-1, num_cls-1))
        rest = T.max(rest, axis=1)
        return T.nnet.relu(rest - corrects + delta).mean()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号