Vowpal Wabbit
|
#include <fstream>
#include <vector>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include "correctedMath.h"
#include "vw_versions.h"
#include "vw.h"
#include "mwt.h"
#include <boost/math/special_functions/digamma.hpp>
#include <boost/math/special_functions/gamma.hpp>
#include <netdb.h>
#include <cstring>
#include <cstdio>
#include <cassert>
#include "no_label.h"
#include "gd.h"
#include "rand48.h"
#include "reductions.h"
#include "array_parameters.h"
#include <boost/version.hpp>
Go to the source code of this file.
Classes | |
class | index_feature |
struct | lda |
struct | initial_weights |
class | set_initial_lda_wrapper< T > |
struct | word_doc_frequency |
struct | feature_pair |
Namespaces | |
anonymous_namespace{lda_core.cc} | |
ldamath | |
Enumerations | |
enum | lda_math_mode { USE_SIMD, USE_PRECISE, USE_FAST_APPROX } |
Functions | |
bool | anonymous_namespace{lda_core.cc}::is_aligned16 (void *ptr) |
float | ldamath::fastlog2 (float x) |
float | ldamath::fastlog (float x) |
float | ldamath::fastpow2 (float p) |
float | ldamath::fastexp (float p) |
float | ldamath::fastpow (float x, float p) |
float | ldamath::fastlgamma (float x) |
float | ldamath::fastdigamma (float x) |
template<typename T , const lda_math_mode mtype> | |
T | ldamath::lgamma (T) |
template<typename T , const lda_math_mode mtype> | |
T | ldamath::digamma (T) |
template<typename T , lda_math_mode mtype> | |
T | ldamath::exponential (T) |
template<typename T , lda_math_mode mtype> | |
T | ldamath::powf (T, T) |
template<> | |
float | ldamath::lgamma< float, USE_PRECISE > (float x) |
template<> | |
float | ldamath::digamma< float, USE_PRECISE > (float x) |
template<> | |
float | ldamath::exponential< float, USE_PRECISE > (float x) |
template<> | |
float | ldamath::powf< float, USE_PRECISE > (float x, float p) |
template<> | |
float | ldamath::lgamma< float, USE_FAST_APPROX > (float x) |
template<> | |
float | ldamath::digamma< float, USE_FAST_APPROX > (float x) |
template<> | |
float | ldamath::exponential< float, USE_FAST_APPROX > (float x) |
template<> | |
float | ldamath::powf< float, USE_FAST_APPROX > (float x, float p) |
template<> | |
float | ldamath::lgamma< float, USE_SIMD > (float x) |
template<> | |
float | ldamath::digamma< float, USE_SIMD > (float x) |
template<> | |
float | ldamath::exponential< float, USE_SIMD > (float x) |
template<> | |
float | ldamath::powf< float, USE_SIMD > (float x, float p) |
template<typename T , const lda_math_mode mtype> | |
void | ldamath::expdigammify (vw &all, T *gamma, T threshold, T initial) |
template<> | |
void | ldamath::expdigammify< float, USE_SIMD > (vw &all, float *gamma, float threshold, float) |
template<typename T , const lda_math_mode mtype> | |
void | ldamath::expdigammify_2 (vw &all, float *gamma, T *norm, const T threshold) |
template<> | |
void | ldamath::expdigammify_2< float, USE_SIMD > (vw &all, float *gamma, float *norm, const float threshold) |
static float | average_diff (vw &all, float *oldgamma, float *newgamma) |
float | theta_kl (lda &l, v_array< float > &Elogtheta, float *gamma) |
static float | find_cw (lda &l, float *u_for_w, float *v) |
float | lda_loop (lda &l, v_array< float > &Elogtheta, float *v, example *ec, float) |
size_t | next_pow2 (size_t x) |
void | save_load (lda &l, io_buf &model_file, bool read, bool text) |
void | return_example (vw &all, example &ec) |
void | learn_batch (lda &l) |
void | learn (lda &l, LEARNER::single_learner &, example &ec) |
void | learn_with_metrics (lda &l, LEARNER::single_learner &base, example &ec) |
void | predict (lda &l, LEARNER::single_learner &base, example &ec) |
void | predict_with_metrics (lda &l, LEARNER::single_learner &base, example &ec) |
template<class T > | |
void | get_top_weights (vw *all, int top_words_count, int topic, std::vector< feature > &output, T &weights) |
void | get_top_weights (vw *all, int top_words_count, int topic, std::vector< feature > &output) |
template<class T > | |
void | compute_coherence_metrics (lda &l, T &weights) |
void | compute_coherence_metrics (lda &l) |
void | end_pass (lda &l) |
template<class T > | |
void | end_examples (lda &l, T &weights) |
void | end_examples (lda &l) |
void | finish_example (vw &, lda &, example &) |
std::istream & | operator>> (std::istream &in, lda_math_mode &mmode) |
LEARNER::base_learner * | lda_setup (options_i &options, vw &all) |
Variables | |
v_array< float > | anonymous_namespace{lda_core.cc}::new_gamma = v_init<float>() |
v_array< float > | anonymous_namespace{lda_core.cc}::old_gamma = v_init<float>() |
enum lda_math_mode |
Enumerator | |
---|---|
USE_SIMD | |
USE_PRECISE | |
USE_FAST_APPROX |
Definition at line 45 of file lda_core.cc.
|
inlinestatic |
Definition at line 639 of file lda_core.cc.
References Search::absdiff(), accumulate(), and vw::lda.
Referenced by lda_loop().
void compute_coherence_metrics | ( | lda & | l, |
T & | weights | ||
) |
Definition at line 1103 of file lda_core.cc.
References lda::all, ACTION_SCORE::cmp(), f, lda::feature_counts, lda::feature_to_example_map, vw::num_bits, lda::topics, and feature::x.
Referenced by compute_coherence_metrics(), and end_pass().
void compute_coherence_metrics | ( | lda & | l | ) |
Definition at line 1238 of file lda_core.cc.
References lda::all, compute_coherence_metrics(), parameters::dense_weights, parameters::sparse, parameters::sparse_weights, and vw::weights.
void end_examples | ( | lda & | l, |
T & | weights | ||
) |
Definition at line 1259 of file lda_core.cc.
References lda::all, correctedExp, lda::decay_levels, v_array< T >::end(), lda::example_t, f, v_array< T >::last(), and vw::lda.
Referenced by end_examples(), and lda_setup().
void end_examples | ( | lda & | l | ) |
Definition at line 1272 of file lda_core.cc.
References lda::all, parameters::dense_weights, end_examples(), parameters::sparse, parameters::sparse_weights, and vw::weights.
void end_pass | ( | lda & | l | ) |
Definition at line 1246 of file lda_core.cc.
References lda::all, lda::compute_coherence_metrics, compute_coherence_metrics(), v_array< T >::empty(), lda::examples, learn_batch(), vw::numpasses, and vw::passes_complete.
Referenced by lda_setup().
|
inlinestatic |
Definition at line 679 of file lda_core.cc.
References lda::topics.
Referenced by lda_loop(), and learn_batch().
Definition at line 1280 of file lda_core.cc.
void get_top_weights | ( | vw * | all, |
int | top_words_count, | ||
int | topic, | ||
std::vector< feature > & | output, | ||
T & | weights | ||
) |
Definition at line 1063 of file lda_core.cc.
References ACTION_SCORE::cmp(), vw::num_bits, and feature::x.
Referenced by get_top_weights().
Definition at line 1094 of file lda_core.cc.
References parameters::dense_weights, get_top_weights(), parameters::sparse, parameters::sparse_weights, and vw::weights.
Definition at line 696 of file lda_core.cc.
References lda::all, average_diff(), v_array< T >::begin(), v_array< T >::clear(), lda::expdigammify(), f, find_cw(), lda::lda_alpha, lda::lda_epsilon, anonymous_namespace{lda_core.cc}::new_gamma, anonymous_namespace{lda_core.cc}::old_gamma, v_array< T >::push_back(), theta_kl(), lda::topics, and vw::weights.
Referenced by learn_batch().
LEARNER::base_learner* lda_setup | ( | options_i & | options, |
vw & | all | ||
) |
Definition at line 1299 of file lda_core.cc.
References add(), VW::config::options_i::add_and_parse(), vw::add_constant, vw::delete_prediction, delete_scalars(), end_examples(), end_pass(), vw::eta, f, VW::finish_example(), LEARNER::init_learner(), vw::initial_t, vw::lda, learn(), learn_with_metrics(), parser::lp, LEARNER::make_base(), VW::config::make_option(), next_pow2(), no_label::no_label_parser, vw::num_bits, vw::p, predict(), predict_with_metrics(), vw::random_weights, parser::ring_size, save_load(), prediction_type::scalars, LEARNER::learner< T, E >::set_end_examples(), LEARNER::learner< T, E >::set_end_pass(), LEARNER::learner< T, E >::set_finish_example(), LEARNER::learner< T, E >::set_save_load(), parser::strict_parse, parameters::stride_shift(), UINT64_ONE, USE_SIMD, VW::config::options_i::was_supplied(), and vw::weights.
Referenced by parse_reductions().
void learn | ( | lda & | l, |
LEARNER::single_learner & | , | ||
example & | ec | ||
) |
Definition at line 999 of file lda_core.cc.
References lda::doc_lengths, lda::examples, f, learn_batch(), lda::minibatch, v_array< T >::push_back(), v_array< T >::size(), and lda::sorted_features.
Referenced by lda_setup(), learn_with_metrics(), and predict().
void learn_batch | ( | lda & | l | ) |
Definition at line 864 of file lda_core.cc.
References lda::all, vw::audit, v_array< T >::begin(), v_array< T >::clear(), correctedExp, lda::decay_levels, lda::digamma(), lda::digammas, lda::doc_lengths, lda::Elogtheta, v_array< T >::empty(), v_array< T >::end(), vw::eta, lda::example_t, lda::examples, lda::expdigammify_2(), f, index_feature::f, find_cw(), v_array< T >::last(), vw::lda, lda::lda_D, lda_loop(), lda::lda_rho, vw::length(), parameters::mask(), vw::power_t, lda::powf(), GD::print_audit_features(), v_array< T >::push_back(), v_array< T >::resize(), return_example(), vw::sd, v_array< T >::size(), lda::sorted_features, parameters::stride(), shared_data::sum_loss, shared_data::sum_loss_since_last_dump, lda::topics, lda::total_lambda, lda::total_new, lda::v, feature::weight_index, and vw::weights.
Referenced by end_pass(), and learn().
void learn_with_metrics | ( | lda & | l, |
LEARNER::single_learner & | base, | ||
example & | ec | ||
) |
Definition at line 1017 of file lda_core.cc.
References lda::all, f, lda::feature_counts, lda::feature_to_example_map, learn(), parameters::mask(), vw::passes_complete, stride_shift(), parameters::stride_shift(), and vw::weights.
Referenced by lda_setup(), and predict_with_metrics().
size_t next_pow2 | ( | size_t | x | ) |
Definition at line 751 of file lda_core.cc.
Referenced by lda_setup().
std::istream& operator>> | ( | std::istream & | in, |
lda_math_mode & | mmode | ||
) |
Definition at line 1282 of file lda_core.cc.
References USE_FAST_APPROX, USE_PRECISE, and USE_SIMD.
void predict | ( | lda & | l, |
LEARNER::single_learner & | base, | ||
example & | ec | ||
) |
void predict_with_metrics | ( | lda & | l, |
LEARNER::single_learner & | base, | ||
example & | ec | ||
) |
Definition at line 1041 of file lda_core.cc.
References learn_with_metrics().
Referenced by lda_setup().
Definition at line 853 of file lda_core.cc.
References vw::current_pass, shared_data::dump_interval, f, vw::final_prediction_sink, VW::finish_example(), vw::holdout_set_off, example::loss, example::num_features, example::pred, MWT::print_scalars(), shared_data::print_update(), vw::progress_add, vw::progress_arg, vw::quiet, polyprediction::scalars, vw::sd, example::tag, example::test_only, shared_data::update(), example::weight, and shared_data::weighted_examples().
Referenced by learn_batch().
Definition at line 793 of file lda_core.cc.
References lda::all, bin_text_read_write_fixed(), parameters::dense_weights, v_array< T >::empty(), io_buf::files, vw::initial_t, initialize_regressor(), vw::lda, lda::lda_D, lda::lda_rho, vw::length(), vw::model_file_ver, vw::num_bits, vw::random_weights, dense_parameters::set_default(), sparse_parameters::set_default(), parameters::sparse, parameters::sparse_weights, parameters::stride(), parameters::strided_index(), VERSION_FILE_WITH_HEADER_ID, and vw::weights.
Referenced by lda_setup().
Definition at line 656 of file lda_core.cc.
References v_array< T >::clear(), lda::digamma(), lda::lda_alpha, lda::lgamma(), v_array< T >::push_back(), and lda::topics.
Referenced by lda_loop().