Vowpal Wabbit
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
lda Struct Reference

Public Member Functions

float digamma (float x)
 
float lgamma (float x)
 
float powf (float x, float p)
 
void expdigammify (vw &all, float *gamma)
 
void expdigammify_2 (vw &all, float *gamma, float *norm)
 
 ~lda ()
 

Public Attributes

size_t topics
 
float lda_alpha
 
float lda_rho
 
float lda_D
 
float lda_epsilon
 
size_t minibatch
 
lda_math_mode mmode
 
v_array< float > Elogtheta
 
v_array< float > decay_levels
 
v_array< float > total_new
 
v_array< example * > examples
 
v_array< float > total_lambda
 
v_array< int > doc_lengths
 
v_array< float > digammas
 
v_array< float > v
 
std::vector< index_featuresorted_features
 
bool compute_coherence_metrics
 
std::vector< uint32_t > feature_counts
 
std::vector< std::vector< size_t > > feature_to_example_map
 
bool total_lambda_init
 
double example_t
 
vwall
 

Static Public Attributes

static constexpr float underflow_threshold = 1.0e-10f
 

Detailed Description

Definition at line 60 of file lda_core.cc.

Constructor & Destructor Documentation

◆ ~lda()

lda::~lda ( )
inline

Definition at line 98 of file lda_core.cc.

References v_array< T >::delete_v().

99  {
103  examples.delete_v();
106  digammas.delete_v();
107  v.delete_v();
108  }
v_array< example * > examples
Definition: lda_core.cc:73
v_array< int > doc_lengths
Definition: lda_core.cc:75
v_array< float > total_lambda
Definition: lda_core.cc:74
v_array< float > decay_levels
Definition: lda_core.cc:71
v_array< float > Elogtheta
Definition: lda_core.cc:70
v_array< float > digammas
Definition: lda_core.cc:76
v_array< float > total_new
Definition: lda_core.cc:72
void delete_v()
Definition: v_array.h:98
v_array< float > v
Definition: lda_core.cc:77

Member Function Documentation

◆ digamma()

float lda::digamma ( float  x)
inline

Definition at line 540 of file lda_core.cc.

References ldamath::digamma< float, USE_FAST_APPROX >(), ldamath::digamma< float, USE_PRECISE >(), ldamath::digamma< float, USE_SIMD >(), USE_FAST_APPROX, USE_PRECISE, and USE_SIMD.

Referenced by learn_batch(), and theta_kl().

541 {
542  switch (mmode)
543  {
544  case USE_FAST_APPROX:
545  // std::cerr << "lda::digamma FAST_APPROX ";
547  case USE_PRECISE:
548  // std::cerr << "lda::digamma PRECISE ";
550  case USE_SIMD:
551  // std::cerr << "lda::digamma SIMD ";
553  default:
554  // Should not happen.
555  std::cerr << "lda::digamma: Trampled or invalid math mode, aborting" << std::endl;
556  abort();
557  return 0.0f;
558  }
559 }
lda_math_mode mmode
Definition: lda_core.cc:68
float digamma< float, USE_SIMD >(float x)
Definition: lda_core.cc:487
float digamma< float, USE_PRECISE >(float x)
Definition: lda_core.cc:441
float digamma< float, USE_FAST_APPROX >(float x)
Definition: lda_core.cc:464

◆ expdigammify()

void lda::expdigammify ( vw all,
float *  gamma 
)
inline

Definition at line 601 of file lda_core.cc.

References ldamath::expdigammify< float, USE_SIMD >(), USE_FAST_APPROX, USE_PRECISE, and USE_SIMD.

Referenced by lda_loop().

602 {
603  switch (mmode)
604  {
605  case USE_FAST_APPROX:
606  ldamath::expdigammify<float, USE_FAST_APPROX>(all, gamma, underflow_threshold, 0.0f);
607  break;
608  case USE_PRECISE:
609  ldamath::expdigammify<float, USE_PRECISE>(all, gamma, underflow_threshold, 0.0f);
610  break;
611  case USE_SIMD:
613  break;
614  default:
615  std::cerr << "lda::expdigammify: Trampled or invalid math mode, aborting" << std::endl;
616  abort();
617  }
618 }
void expdigammify< float, USE_SIMD >(vw &all, float *gamma, float threshold, float)
Definition: lda_core.cc:511
lda_math_mode mmode
Definition: lda_core.cc:68
vw * all
Definition: lda_core.cc:89
static constexpr float underflow_threshold
Definition: lda_core.cc:91

◆ expdigammify_2()

void lda::expdigammify_2 ( vw all,
float *  gamma,
float *  norm 
)
inline

Definition at line 620 of file lda_core.cc.

References ldamath::expdigammify_2< float, USE_SIMD >(), USE_FAST_APPROX, USE_PRECISE, and USE_SIMD.

Referenced by learn_batch().

621 {
622  switch (mmode)
623  {
624  case USE_FAST_APPROX:
625  ldamath::expdigammify_2<float, USE_FAST_APPROX>(all, gamma, norm, underflow_threshold);
626  break;
627  case USE_PRECISE:
628  ldamath::expdigammify_2<float, USE_PRECISE>(all, gamma, norm, underflow_threshold);
629  break;
630  case USE_SIMD:
632  break;
633  default:
634  std::cerr << "lda::expdigammify_2: Trampled or invalid math mode, aborting" << std::endl;
635  abort();
636  }
637 }
lda_math_mode mmode
Definition: lda_core.cc:68
vw * all
Definition: lda_core.cc:89
void expdigammify_2< float, USE_SIMD >(vw &all, float *gamma, float *norm, const float threshold)
Definition: lda_core.cc:528
static constexpr float underflow_threshold
Definition: lda_core.cc:91

◆ lgamma()

float lda::lgamma ( float  x)
inline

Definition at line 561 of file lda_core.cc.

References ldamath::lgamma< float, USE_FAST_APPROX >(), ldamath::lgamma< float, USE_PRECISE >(), ldamath::lgamma< float, USE_SIMD >(), USE_FAST_APPROX, USE_PRECISE, and USE_SIMD.

Referenced by theta_kl().

562 {
563  switch (mmode)
564  {
565  case USE_FAST_APPROX:
566  // std::cerr << "lda::lgamma FAST_APPROX ";
568  case USE_PRECISE:
569  // std::cerr << "lda::lgamma PRECISE ";
571  case USE_SIMD:
572  // std::cerr << "lda::gamma SIMD ";
574  default:
575  std::cerr << "lda::lgamma: Trampled or invalid math mode, aborting" << std::endl;
576  abort();
577  return 0.0f;
578  }
579 }
lda_math_mode mmode
Definition: lda_core.cc:68
float lgamma< float, USE_PRECISE >(float x)
Definition: lda_core.cc:436
float lgamma< float, USE_FAST_APPROX >(float x)
Definition: lda_core.cc:459
float lgamma< float, USE_SIMD >(float x)
Definition: lda_core.cc:482

◆ powf()

float lda::powf ( float  x,
float  p 
)
inline

Definition at line 581 of file lda_core.cc.

References ldamath::powf< float, USE_FAST_APPROX >(), ldamath::powf< float, USE_PRECISE >(), ldamath::powf< float, USE_SIMD >(), USE_FAST_APPROX, USE_PRECISE, and USE_SIMD.

Referenced by learn_batch().

582 {
583  switch (mmode)
584  {
585  case USE_FAST_APPROX:
586  // std::cerr << "lda::powf FAST_APPROX ";
588  case USE_PRECISE:
589  // std::cerr << "lda::powf PRECISE ";
591  case USE_SIMD:
592  // std::cerr << "lda::powf SIMD ";
593  return ldamath::powf<float, USE_SIMD>(x, p);
594  default:
595  std::cerr << "lda::powf: Trampled or invalid math mode, aborting" << std::endl;
596  abort();
597  return 0.0f;
598  }
599 }
float powf< float, USE_SIMD >(float x, float p)
Definition: lda_core.cc:497
lda_math_mode mmode
Definition: lda_core.cc:68
float powf< float, USE_PRECISE >(float x, float p)
Definition: lda_core.cc:451
float powf< float, USE_FAST_APPROX >(float x, float p)
Definition: lda_core.cc:474

Member Data Documentation

◆ all

vw* lda::all

◆ compute_coherence_metrics

bool lda::compute_coherence_metrics

Definition at line 80 of file lda_core.cc.

Referenced by end_pass().

◆ decay_levels

v_array<float> lda::decay_levels

Definition at line 71 of file lda_core.cc.

Referenced by end_examples(), and learn_batch().

◆ digammas

v_array<float> lda::digammas

Definition at line 76 of file lda_core.cc.

Referenced by learn_batch().

◆ doc_lengths

v_array<int> lda::doc_lengths

Definition at line 75 of file lda_core.cc.

Referenced by learn(), and learn_batch().

◆ Elogtheta

v_array<float> lda::Elogtheta

Definition at line 70 of file lda_core.cc.

Referenced by learn_batch().

◆ example_t

double lda::example_t

Definition at line 88 of file lda_core.cc.

Referenced by end_examples(), and learn_batch().

◆ examples

v_array<example *> lda::examples

Definition at line 73 of file lda_core.cc.

Referenced by end_pass(), learn(), and learn_batch().

◆ feature_counts

std::vector<uint32_t> lda::feature_counts

Definition at line 83 of file lda_core.cc.

Referenced by compute_coherence_metrics(), and learn_with_metrics().

◆ feature_to_example_map

std::vector<std::vector<size_t> > lda::feature_to_example_map

Definition at line 84 of file lda_core.cc.

Referenced by compute_coherence_metrics(), and learn_with_metrics().

◆ lda_alpha

float lda::lda_alpha

Definition at line 63 of file lda_core.cc.

Referenced by lda_loop(), and theta_kl().

◆ lda_D

float lda::lda_D

Definition at line 65 of file lda_core.cc.

Referenced by learn_batch(), and save_load().

◆ lda_epsilon

float lda::lda_epsilon

Definition at line 66 of file lda_core.cc.

Referenced by lda_loop().

◆ lda_rho

float lda::lda_rho

Definition at line 64 of file lda_core.cc.

Referenced by learn_batch(), and save_load().

◆ minibatch

size_t lda::minibatch

Definition at line 67 of file lda_core.cc.

Referenced by learn().

◆ mmode

lda_math_mode lda::mmode

Definition at line 68 of file lda_core.cc.

◆ sorted_features

std::vector<index_feature> lda::sorted_features

Definition at line 78 of file lda_core.cc.

Referenced by learn(), and learn_batch().

◆ topics

size_t lda::topics

Definition at line 62 of file lda_core.cc.

Referenced by compute_coherence_metrics(), find_cw(), lda_loop(), learn_batch(), and theta_kl().

◆ total_lambda

v_array<float> lda::total_lambda

Definition at line 74 of file lda_core.cc.

Referenced by learn_batch().

◆ total_lambda_init

bool lda::total_lambda_init

Definition at line 86 of file lda_core.cc.

◆ total_new

v_array<float> lda::total_new

Definition at line 72 of file lda_core.cc.

Referenced by learn_batch().

◆ underflow_threshold

constexpr float lda::underflow_threshold = 1.0e-10f
static

Definition at line 91 of file lda_core.cc.

◆ v

v_array<float> lda::v

Definition at line 77 of file lda_core.cc.

Referenced by learn_batch().


The documentation for this struct was generated from the following file: