Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nmf bugfix #2466

Merged
merged 2 commits into from
May 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions gensim/models/nmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,9 @@ def get_document_topics(self, bow, minimum_probability=None,
if normalize is None:
normalize = self.normalize
if normalize:
h /= h.sum()
the_sum = h.sum()
if the_sum:
h /= the_sum

return [
(idx, proba)
Expand Down Expand Up @@ -587,9 +589,9 @@ def update(self, corpus, chunksize=None, passes=None, eval_every=None):
raise ValueError("Corpus is an iterator, only `passes=1` is valid.")

logger.info(
"running NMF training, %s topics, %i passes over the supplied corpus of %i documents, evaluating l2 norm "
"running NMF training, %s topics, %i passes over the supplied corpus of %s documents, evaluating l2 norm "
"every %i documents",
self.num_topics, passes, lencorpus if lencorpus < np.inf else "?", evalafter,
self.num_topics, passes, lencorpus, evalafter,
)

chunk_overall_idx = 1
Expand Down Expand Up @@ -623,7 +625,7 @@ def update(self, corpus, chunksize=None, passes=None, eval_every=None):
chunk_len = len(chunk)

logger.info(
"PROGRESS: pass %i, at document #%i/%i",
"PROGRESS: pass %i, at document #%i/%s",
pass_, chunk_idx * chunksize + chunk_len, lencorpus
)

Expand Down