它在配合使用perp_tol
參數來評估收斂,並沒有保存迭代之間,每source:
for i in xrange(max_iter):
# ...
# check perplexity
if evaluate_every > 0 and (i + 1) % evaluate_every == 0:
doc_topics_distr, _ = self._e_step(X, cal_sstats=False,
random_init=False,
parallel=parallel)
bound = self.perplexity(X, doc_topics_distr,
sub_sampling=False)
if self.verbose:
print('iteration: %d, perplexity: %.4f'
% (i + 1, bound))
if last_bound and abs(last_bound - bound) < self.perp_tol:
break
last_bound = bound
self.n_iter_ += 1
不過請注意,你可以輕鬆地適應現有的源通過做到這一點(1 )將線self.saved_bounds = []
到__init__
方法(2)加入self.bounds.append(bound)
上面,像這樣:
if last_bound and abs(last_bound - bound) < self.perp_tol:
break
last_bound = bound
self.bounds.append(bound)
根據你保存更新類,Y您還必須修改文件頂部的導入以引用scikit-learn中的完整模塊路徑。