def update_model(self, y):
y = self.proj.reduce(np.array([y]).T)
y = preprocessing.normalize(y, norm='l2', axis=0) # (k, 1)
if not hasattr(self, 'B'):
self.p_failure = 0.1
self.B = np.zeros((self.k, self.ell))
self.A = np.array([])
U, s, V = ln.svd(self.B, full_matrices=False)
# update the tracked orthonormal bases
self.U_r = U[:, :self.r]
if self.A.size == 0:
self.A = np.empty_like(y)
self.A[:] = y[:]
else:
self.A = np.concatenate((self.A, y), axis=1)
if np.count_nonzero(self.A) >= (self.ell * self.k) or self.A.shape[1] == self.k:
B = self.__boosted_sparse_shrink(self.A, self.ell, self.p_failure)
self.B = self.__dense_shrink(np.concatenate((self.B, B), axis=1), self.ell)
self.A = np.array([])
评论列表
文章目录