risk.py 文件源码

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

项目:operalib 作者: operalib 项目源码 文件源码
def functional_grad(self, coefs, ground_truth, Gram,
                        weight=None, zeronan=None):
        """Compute the gradient of the Empirical OVK ridge risk.

        Parameters
        ----------
        coefs : {vector-like}, shape = [n_samples1 * n_targets]
            Coefficient to optimise

        ground_truth : {vector-like}
            Targets samples

        Gram : {LinearOperator}
            Gram matrix acting on the coefs

        weight: {LinearOperator}

        zeronan: {LinearOperator}

        Returns
        -------
        {vector-like} : gradient of the Empirical OVK ridge risk
        """
        np = ground_truth.size
        pred = Gram * coefs
        vgt = masked_invalid(ground_truth)
        vgt[where(vgt.mask)] = pred[where(vgt.mask)]
        if weight is None or zeronan is None:
            res = pred - vgt
        else:
            res = weight * pred - zeronan * vgt
        return Gram * res / np + self.lbda * pred / np
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号