当前位置: 首页>>代码示例>>C++>>正文


C++ Corpus::LoadData方法代码示例

本文整理汇总了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");
}
开发者ID:lijiankou,项目名称:mllib-1,代码行数:33,代码来源:estimate.cpp

示例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");
}
开发者ID:lijiankou,项目名称:bigdata,代码行数:33,代码来源:lda_app.cpp

示例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);
}
开发者ID:lijiankou,项目名称:mllib-1,代码行数:20,代码来源:estimate.cpp


注:本文中的Corpus::LoadData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。