本文整理汇总了C++中Corpus::LoadData方法的典型用法代码示例。如果您正苦于以下问题:C++ Corpus::LoadData方法的具体用法?C++ Corpus::LoadData怎么用?C++ Corpus::LoadData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Corpus
的用法示例。
在下文中一共展示了Corpus::LoadData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LdaApp
void LdaApp() {
long t1;
(void) time(&t1);
seedMT(t1);
float em_converged = 1e-4;
int em_max_iter = FLAGS_em_iterate;
int em_estimate_alpha = 1; //1 indicate estimate alpha and 0 use given value
int var_max_iter = FLAGS_var_iterate;
double var_converged = 1e-6;
double initial_alpha = FLAGS_alpha;
int topic = FLAGS_topic_num;
Corpus train;
Corpus test;
train.LoadData(FLAGS_cor_train);
test.LoadData(FLAGS_cor_test);
LOG(INFO) << train.Len()<< " " << test.Len();
LdaModel m;
LDA lda;
lda.Init(em_converged, em_max_iter, em_estimate_alpha, var_max_iter,
var_converged, initial_alpha, topic);
Str type = "seeded";
lda.RunEM(type, train, test, &m);
VVReal gamma;
VVVReal phi;
lda.Infer(test, m, &gamma, &phi);
WriteStrToFile(Join(gamma, " ", "\n"), "./model/gamma");
WriteStrToFile(Join(m.log_prob_w, topic, train.num_terms), "./model/beta");
WriteStrToFile(Join(phi, " ", "\n", "\n\n"), "./model/phi");
}
示例2: App
void App() {
long t1;
(void) time(&t1);
seedMT(t1);
float em_converged = 1e-4;
int em_max_iter = 20;
int em_estimate_alpha = 1; //1 indicate estimate alpha and 0 use given value
int var_max_iter = 30;
double var_converged = 1e-6;
double initial_alpha = 0.1;
int n_topic = 30;
LDA lda;
lda.Init(em_converged, em_max_iter, em_estimate_alpha, var_max_iter,
var_converged, initial_alpha, n_topic);
Corpus cor;
//Str data = "../../data/ap.dat";
Str data = "lda_data";
cor.LoadData(data);
Corpus train;
Corpus test;
double p = 0.8;
SplitData(cor, p, &train, &test);
Str type = "seeded";
LdaModel m;
lda.RunEM(type, train, test, &m);
LOG(INFO) << m.alpha;
VVReal gamma;
VVVReal phi;
lda.Infer(test, m, &gamma, &phi);
WriteStrToFile(Join(gamma, " ", "\n"), "gamma");
WriteStrToFile(Join(phi, " ", "\n", "\n\n"), "phi");
}
示例3: MGRTMApp
void MGRTMApp() {
ml::Converged converged;
converged.em_converged_ = 1e-4;
converged.em_max_iter_ = 100;
converged.var_converged_ = 1e-4;
converged.var_max_iter_ = 10;
int rho = 3;
VarMGRTM var;
var.Init(converged,rho);
var.Load(FLAGS_net_path, FLAGS_cor_path, FLAGS_neg_times);
Str path(FLAGS_cor_path);
Corpus cor;
cor.LoadData(path);
MGRTM m;
m.Init(2, FLAGS_local_topic, FLAGS_global_topic, cor.TermNum(), 1, 0.01, 0.01);
var.RunEM(&m);
}