LDA++
|
#include <SupervisedEStep.hpp>
Public Member Functions | |
SupervisedEStep (size_t e_step_iterations=10, Scalar e_step_tolerance=1e-2, size_t fixed_point_iterations=20, Scalar compute_likelihood=1.0, int random_state=0) | |
std::shared_ptr< parameters::Parameters > | doc_e_step (const std::shared_ptr< corpus::Document > doc, const std::shared_ptr< parameters::Parameters > parameters) override |
Public Member Functions inherited from ldaplusplus::em::AbstractEStep< Scalar > | |
AbstractEStep (int random_state) | |
virtual void | e_step () override |
Public Member Functions inherited from ldaplusplus::events::EventDispatcherComposition | |
std::shared_ptr< EventDispatcherInterface > | get_event_dispatcher () |
void | set_event_dispatcher (std::shared_ptr< EventDispatcherInterface > dispatcher) |
Additional Inherited Members | |
Protected Member Functions inherited from ldaplusplus::em::AbstractEStep< Scalar > | |
bool | converged (const Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > &gamma_old, const Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > &gamma, Scalar tolerance) |
PRNG & | get_prng () |
SupervisedEStep implements the categorical supervised LDA expectation step.
As in UnsupervisedEStep the parameters of a distribution ( \(\gamma\) and \(\phi\)) are computed such that the likelihood of generating each document is maximized. For all supervised LDA variants except for generating the document the likelihood of generating the label is also maximized.
The solution implemented in SupervisedEStep is the one presented in paper [2].
[1] Mcauliffe, Jon D., and David M. Blei. "Supervised topic models." Advances in neural information processing systems. 2008
[2] Chong, Wang, David Blei, and Fei-Fei Li. "Simultaneous image classification and annotation." Computer Vision and Pattern Recognition, 2009 CVPR 2009 IEEE Conference on. IEEE, 2009
ldaplusplus::em::SupervisedEStep< Scalar >::SupervisedEStep | ( | size_t | e_step_iterations = 10 , |
Scalar | e_step_tolerance = 1e-2 , |
||
size_t | fixed_point_iterations = 20 , |
||
Scalar | compute_likelihood = 1.0 , |
||
int | random_state = 0 |
||
) |
e_step_iterations | The max number of times to alternate between maximizing for \(\gamma\) and for \(\phi\). |
e_step_tolerance | The minimum relative change in the variational parameter \(\gamma\). |
fixed_point_iterations | The number of fixed point iterations used in the maximization for \(\phi\). |
compute_likelihood | The percentage of documents to compute likelihood for (1.0 means compute for every document) |
random_state | An initial seed value for any random numbers needed |
|
overridevirtual |
Maximize the ELBO w.r.t. to \(\phi\) and \(\gamma\).
The following steps are the mathematics that are implemented where \(\beta\) are the topics, \(\eta\) are the logistic regression parameters, \(i\) is the topic subscript, \(n\) is the word subscript, \(\hat{y}\) is the class subscript, \(y\) is the document's class, \(w_n\) is n-th word vocabulary index, \(\alpha\) is the Dirichlet prior and finally \(\Psi(\cdot)\) is the first derivative of the \(\log \Gamma\) function.
fixed_point_iterations
doc | A single document |
parameters | An instance of class Parameters, which contains all necessary model parameters for e-step's implementation |
Implements ldaplusplus::em::EStepInterface< Scalar >.