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


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

本文整理汇总了C++中Corpus::getSamples方法的典型用法代码示例。如果您正苦于以下问题:C++ Corpus::getSamples方法的具体用法?C++ Corpus::getSamples怎么用?C++ Corpus::getSamples使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Corpus的用法示例。


在下文中一共展示了Corpus::getSamples方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: validate

void dtw_model::validate(Corpus& corpus) {
  static const size_t MINIATURE_SIZE = 10000;
  static vector<tsample> samples = corpus.getSamples(MINIATURE_SIZE);
  static double objective = 0;
  static bool aboutToStop = false;
  static const double SOFT_THRESHOLD = 2e-6 * _learning_rate;
  static const double HARD_THRESHOLD = SOFT_THRESHOLD * 0.1;
  static size_t MIN_ITERATION = 128;
  static size_t itr = 0;

  double obj = calcObjective(samples);
  double diff = obj - objective;
  double improveRate = abs(diff / objective);

  printf("objective = %.7f \t prev-objective = %.7f \n", obj, objective);
  printf("improvement rate on dev-set of size %lu = %.6e ", samples.size(), improveRate);
  printf(", still "GREEN"%.0f"COLOREND" times of threshold \n", improveRate / SOFT_THRESHOLD);

  if (itr > MIN_ITERATION) {
    if (improveRate != improveRate)
      exit(-1);
    
    if (improveRate < HARD_THRESHOLD) {
      printf("\nObjective function on dev-set is no longer decreasing...\n");
      printf("Training process "GREEN"DONE"COLOREND"\n");
      // doPause();
      exit(0);
    }
    else if (aboutToStop || improveRate < SOFT_THRESHOLD) {
      aboutToStop = true;
      _learning_rate /= 2;
    }
  }

  objective = obj;
  ++itr;
}
开发者ID:botonchou,项目名称:TrainableDTW,代码行数:37,代码来源:trainable_dtw.cpp


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