Utils and Matutils changes#1062
Merged
Merged
Conversation
Merged
piskvorky
reviewed
Dec 28, 2016
| if len(doc1) == 0: # sparse documents must have a __len__ function (list, tuple...) | ||
| return True, obj # the first document is empty=>assume this is a corpus | ||
| id1, val1 = next(iter(doc1)) # if obj is a numpy array, it resolves to False here | ||
| id1, val1 = next(iter(doc1)) # if obj is a np array, it resolves to False here |
Owner
There was a problem hiding this comment.
This replacement (and the one above) look unnecessary, the original was clearer.
Contributor
Author
There was a problem hiding this comment.
Cool, will fix it
tmylk
reviewed
Dec 28, 2016
| def lda_e_step(doc_word_ids, doc_word_counts, alpha, beta, max_iter=100): | ||
| gamma = np.ones(len(alpha)) | ||
| expElogtheta = np.exp(dirichlet_expectation(gamma)) | ||
| expElogtheta = np.exp(matutils.dirichlet_expectation(gamma)) |
Contributor
There was a problem hiding this comment.
better to add from matutils import dirichlet_expectation to avoid this change
Contributor
|
Thanks for the improvement! |
piskvorky
reviewed
Dec 29, 2016
| def run(self): | ||
| if self.as_numpy: | ||
| import numpy # don't clutter the global namespace with a dependency on numpy | ||
| import np # don't clutter the global namespace with a dependency on numpy |
Owner
There was a problem hiding this comment.
Looks like the global module namespace already has numpy, so this line is unnecessary.
|
|
||
| """ | ||
| import numpy | ||
| import numpy as np |
Owner
There was a problem hiding this comment.
Already imported at module level, this line no longer unnecessary.
jayantj
pushed a commit
to jayantj/gensim
that referenced
this pull request
Jan 4, 2017
* Utils, Matutils changes * Changed comments * changed matutils import
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
dirichlet_expectationtomatutilsas the same code was being used in bothldamodelandhdpmodel.numpyinutilsandmatutilstonp, keeping it uniform across the package.hdpmodelto make it consistent withldamodel