Skip to content

Commit

Permalink
Optimize performance of Author-Topic model (#2978)
Browse files Browse the repository at this point in the history
* take out common part of expression in ATModel

* Update atmodel.py

* Update atmodel.py

* Update CHANGELOG.md

Co-authored-by: Michael Penkov <m@penkov.dev>
  • Loading branch information
horpto and mpenkov authored May 12, 2021
1 parent 69b8cb5 commit 52281eb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Changes
- [#3115](https://github.com/RaRe-Technologies/gensim/pull/3115): Make LSI dispatcher CLI param for number of jobs optional, by [@robguinness](https://github.com/robguinness))
- Update link to Hoffman paper (online VB LDA) (PR [#3133](https://github.com/RaRe-Technologies/gensim/pull/3133), [@jonaschn](https://github.com/jonaschn))
- fix bug when loading saved Phrases model (PR [#3116](https://github.com/RaRe-Technologies/gensim/pull/3116), [@aloknayak29](https://github.com/aloknayak29))
- Optimize performance of Author-Topic model (PR [#2978](https://github.com/RaRe-Technologies/gensim/pull/2978), [@horpto](https://github.com/horpto))

### :+1: Improvements

### Documentation

Expand Down
7 changes: 5 additions & 2 deletions gensim/models/atmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,12 @@ def inference(self, chunk, author2doc, doc2author, rhot, collect_sstats=False, c

# Update gamma.
# phi is computed implicitly below,
dot = np.dot(cts / phinorm, expElogbetad.T)
for ai, a in enumerate(authors_d):
tilde_gamma[ai, :] = self.alpha + len(self.author2doc[self.id2author[a]])\
* expElogthetad[ai, :] * np.dot(cts / phinorm, expElogbetad.T)
tilde_gamma[ai, :] = (
self.alpha
+ len(self.author2doc[self.id2author[a]]) * expElogthetad[ai, :] * dot
)

# Update gamma.
# Interpolation between document d's "local" gamma (tilde_gamma),
Expand Down

0 comments on commit 52281eb

Please sign in to comment.