katsuya94 / hmm-lda Goto Github PK
View Code? Open in Web Editor NEW"Integrating Topics and Syntax" T.L. Griffiths et al. Python implementation of HMM-LDA
License: MIT License
"Integrating Topics and Syntax" T.L. Griffiths et al. Python implementation of HMM-LDA
License: MIT License
Hi,
I was trying to re-implement your python code to c++ so that it can handle larger data. While doing so I realized that the function run_counts()
is the main performance bottleneck. Specifically the loops where you compute
self.num_same_words_assigned_to_topic = [self.count_num_same_words_assigned_to_topic(word) for word in xrange(self.vocab_size)]
count_num_same_words_assigned_to_topic(word)
is a 2D loop of documents * topics
and it is called vocab_size
times (one time for each word in the vocab. Calling this function for each word is redundant because it can be done in documents * topics
iterations like so
for(int i = 0; i < n_documents; i++) {
doc_size = documents[i].size();
for(int j = 0; j < doc_size; j++) {
word = documents[i][j];
if(class_assignments[i][j] == 0)
num_same_words_assigned_to_topic[word][topic_assignments[i][j]] += 1;
}
}
Kindly note that this is a c++ code snippet but this can be very easily ported to python. This should give a good speed improvement in the overall performance. Correct me if I'm doing something wrong.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.