penalty.py 文件源码

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

项目:dalila 作者: slipguru 项目源码 文件源码
def apply_prox_operator(self, x, gamma):
        if self._lambda < 0:
            logging.error("A negative regularisation parameter was used")
            raise ValueError("A negative regularization parameter was used")

        l = list(set().union(*self._groups))
        if not (l == list(np.arange(x.shape[1]))):
            logging.error("The groups in group lasso must cover all the "
                          "features")
            raise ValueError("The groups in group lasso must cover all the "
                          "features")

        for pair in combinations(self._groups, r=2):
            if len(set(pair[0]) & set(pair[1])) > 0:
                logging.error("There are overlapping groups")
                raise ValueError("There are overlapping groups")

        new_x = np.zeros_like(x)
        for r in range(0, x.shape[0]):
            for g in self._groups:
                new_x[r, g] = self.prox_operator(x[r, g], gamma)
        return new_x
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号