recsys.py 文件源码

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

项目:modl 作者: arthurmensch 项目源码 文件源码
def _single_sample_update(self, X, i, w):
        n_features = X.shape[1]
        if X.indptr[i + 1] - X.indptr[i] != 0:
            X_subset = X.data[X.indptr[i]:X.indptr[i + 1]]
            subset = X.indices[X.indptr[i]:X.indptr[i + 1]]
            len_subset = subset.shape[0]
            reduction = n_features / len_subset
            self.feature_n_iter_[subset] += 1
            components_subset = self.components_[:, subset]
            Dx = components_subset.dot(X_subset)
            G = components_subset.dot(components_subset.T)
            G.flat[::self.n_components + 1] += self.alpha / reduction
            self.code_[i] = linalg.solve(G, Dx)
            code = self.code_[i]
            w_B = np.minimum(1,
                             w * self.n_iter_ / self.feature_n_iter_[subset])
            self.B_[:, subset] *= 1 - w_B
            self.B_[:, subset] += np.outer(code, X_subset * w_B)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号