⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hsrch_11.cc

📁 这是一个从音频信号里提取特征参量的程序
💻 CC
📖 第 1 页 / 共 5 页
字号:
      }      // instance pruning      //      if (getSearchLevel(level_num).useInstance()) {	if (debug_level_d >= Integral::DETAILED) {	  Console::put(L"\ninstance pruning after propagation instances up");	}		instancePruneInstance(level_num);      }            if (debug_level_d >= Integral::DETAILED) {	String output;        	output.assign(L"propagating instances down from level: ");	output.concat(level_num);	output.concat(L" in frame: ");    	output.concat(current_frame_d);	Console::put(output);      }            status = (propagateInstancesDown(level_num) || status);    }  }  // print debugging information  //  if (debug_level_d >= Integral::ALL) {        String val;    val.assign(L"old frame:");    val.concat(current_frame_d);    val.concat(L" instances left:");    val.concat(getActiveInstances(num_levels - 1));    Console::put(val);  }  // exit gracefully  //  return true;  }// method: propagateTraces//// arguments: none//// return: logical error status//// move traces through the hierarchy until all active traces are ready to be// evaluated//boolean HierarchicalSearch::propagateTraces() {    // define local variables  //  long level_num = 0;  boolean status = true;  long num_levels = getNumLevels();  String out;    // clear the hypothesis list since we are generating new hypotheses for this  // frame  //  clearValidHypsTrace();  // move all traces forward in the search space. we do this by  // pushing traces up and down in the hierarchy until they all rest  // in a state that is ready to be evaluated. if there is an infinite  // "skip" loop in the search graph then this process will go into an  // infinite loop. an infinite skip loop is of the form:  // A -> B && B -> A.  // this infinite loop structure may be masked by the fact that it   // extends over multiple search levels.  //   // when we exit the while loop below, all traces should be in the lowest  // level and should be ready for evaluation.  //  while ((getActiveTraces() != getActiveTraces(num_levels - 1)) ||	 status) {        // status indicates whether any movement in the traces happened    //    status = false;    for (level_num = (long)initial_level_d;  level_num < num_levels; level_num++) {      if (getSearchLevel(level_num).useBeam()) {	max_trace_scores_d(level_num) = Trace::INACTIVE_SCORE;      }    }        // work from the bottom up until we reach a point where all traces    // are ready to descend again. this segment takes care of    // posterior scores such as nsymbol probabilities and applies    // pruning (beam and instance) at each level.    //    for (level_num = num_levels - 1; level_num >= (long)initial_level_d; level_num--) {            if (debug_level_d >= Integral::DETAILED) {      	String output;        	output.assign(L"propagating traces up from level: ");	output.concat(level_num);	output.concat(L" in frame: ");    	output.concat(current_frame_d);	Console::put(output);      }            // propagate up      //      status = (propagateTracesUp(level_num) || status);    }        // propagate traces down the hierarchy, carrying out viterbi pruning    // as we go.    //    for (level_num = (long)initial_level_d;  level_num < num_levels - 1; level_num++) {      // beam pruning      //      if (getSearchLevel(level_num).useBeam()) {		if (debug_level_d >= Integral::DETAILED) {	  Console::put(L"\nbeam pruning after propagation trace up");	}	beamPruneTrace(level_num);      }      // instance pruning      //      if (getSearchLevel(level_num).useInstance()) {	if (debug_level_d >= Integral::DETAILED) {	  Console::put(L"\ninstance pruning after propagation trace up");	}		instancePruneTrace(level_num);      }            if (debug_level_d >= Integral::DETAILED) {	String output;        	output.assign(L"propagating traces down from level: ");	output.concat(level_num);	output.concat(L" in frame: ");    	output.concat(current_frame_d);	Console::put(output);      }            // propagate down      //      status = (propagateTracesDown(level_num) || status);    }  }    // exit gracefully  //  return true;}// method: evaluateInstanceModels//// arguments: (none)//// return: logical error status.//// evaluate all statistical models//boolean HierarchicalSearch::evaluateInstanceModels() {  // define local variables  //  String out;  String val;  long level_num = getNumLevels() - 1;  boolean end_loop = false;  SearchSymbol item;    Instance* curr_instance = (Instance*)NULL;  Instance* next_instance = (Instance*)NULL;    GraphVertex<SearchNode>* curr_vert = (GraphVertex<SearchNode>*)NULL;  DiGraph<SearchNode>* parent_graph = (DiGraph<SearchNode>*)NULL;     BiGraphVertex<TrainNode>* vertex = (BiGraphVertex<TrainNode>*)NULL;    // output the frame information  //  if (debug_level_d >= Integral::DETAILED) {    out.assign(L"\n-> evaluating data in frame: ");    val.assign((ullong)current_frame_d);    out.concat(val);    Console::put(out);  }  // when we are NOT in context generation mode -  //   evaluate each instance at the lowest level of the hierarchy  //  if (!context_generation_mode_d && (search_mode_d != TRAIN)) {    // if the beam pruning is required at this level    //    initialize the maximal instance score    //    if(getSearchLevel(level_num).useBeam()) {      max_instance_scores_d(level_num) = Instance::INACTIVE_SCORE;    }      // loop over all active instances and score them    //        for (boolean more_instances = instance_lists_d(level_num).gotoFirst();	 more_instances;	 more_instances = instance_lists_d(level_num).gotoNext()) {            // get the current vertex in the search graph      //      curr_instance = instance_lists_d(level_num).getCurr();      curr_vert = curr_instance->getSymbol()->getCentralVertex();            // evaluate the statistical model      //      float model_score =	curr_vert->getItem()->evaluateData(features_d, (long)current_frame_d);      float new_score = curr_instance->getScore() + model_score;      curr_instance->setScore(new_score);      if (search_mode_d == TRAIN) {		// update the trained node in the trellis	//	vertex = curr_instance->getReference();		if (vertex == (BiGraphVertex<TrainNode>*)NULL) {	  return Error::handle(name(), L"evaluateTraceModels", Error::ARG, __FILE__, __LINE__);	}	vertex->getItem()->setScore(model_score);      }            // update the maximal instance score for the beam pruning      //      if(getSearchLevel(level_num).useBeam()	 && (new_score > max_instance_scores_d(level_num))) {	max_instance_scores_d(level_num) = new_score;      }    }    // beam pruning at this level    //    if (getSearchLevel(getNumLevels() - 1).useBeam()) {      if (debug_level_d >= Integral::DETAILED) {	Console::put(L"\nbeam pruning after the model evaluation");      }            beamPruneInstance(getNumLevels() - 1);    }    // instance pruning at this level    //    if (getSearchLevel(getNumLevels() - 1).useInstance()) {      if (debug_level_d >= Integral::DETAILED) {	Console::put(L"\ninstance pruning after the model evaluation");      }            instancePruneInstance(getNumLevels() - 1);    }      }    // update current frame  //        - instances generated later will correspond to the next frame  //  current_frame_d += 1 ;  // print debugging information  //  if (debug_level_d >= Integral::DETAILED) {    out.assign(L"\n-> time changed to: ");    out.concat(current_frame_d);    Console::put(out);  }    // we mark the current end of the list so we only propagate those instances  // forward that were just evaluated  //  instance_lists_d(level_num).gotoLast();  instance_lists_d(level_num).setMark();  instance_lists_d(level_num).gotoFirst();  // print debugging information  //  if (debug_level_d >= Integral::DETAILED) {    Console::put(L"\npropagating instances forward after the model evaluation");  }    // loop until we have propagated all evaluated instances forward  //  end_loop = instance_lists_d(level_num).isEmpty();  while (!end_loop) {        end_loop = instance_lists_d(level_num).isMarkedElement();        // get the current vertex in the search graph    //    curr_instance = instance_lists_d(level_num).getCurr();    curr_vert = curr_instance->getSymbol()->getLastVertex();    parent_graph = curr_vert->getParentGraph();    // when we are in context generation mode -    //   we do not need to evaluate the states at the lowest level    //    if (context_generation_mode_d) {      // create a new instance      //      next_instance = new Instance(*curr_instance);      next_instance->setFrame((ulong)current_frame_d);      // update the history with the next node at this level      //      next_instance->getSymbol()->assignAndAdvance((ulong)parent_graph->getTerm());      // set the backpointer      //      next_instance->setBackPointer(curr_instance);            // add the instance to this level's instance list      //      instance_lists_d(level_num).insertLast(next_instance);            if (debug_level_d >= Integral::DETAILED) { 	printNewPath(next_instance, curr_instance);      }            // bump the current instance off of the instance list      //      instance_lists_d(level_num).removeFirst(curr_instance);      if (curr_instance->getRefCount() < 1) {	Instance::deleteInstance(curr_instance, true);      }      instance_lists_d(level_num).gotoFirst();      // evaluate the next instance in the list      //      continue;    }        // if this instance is inactive, then delete it    //    if (!curr_instance->isActive()) {            // bump the current instance off of the instance list      //      if (debug_level_d >= Integral::ALL) {	Console::put(L" not active");      }            instance_lists_d(level_num).removeFirst(curr_instance);      Instance::deleteInstance(curr_instance, true);    }        // else, extend paths and apply viterbi pruning    //    else {            // extend all paths from that vertex and apply viterbi pruning      //      for (boolean more_paths = curr_vert->gotoFirst(); more_paths;	   more_paths = curr_vert->gotoNext()) {		// create a new instance	//	next_instance = new Instance(*curr_instance);	next_instance->setFrame((ulong)current_frame_d);	// determine the symbol insertion penalty and transition scale factor	//	float tr_scale = getSearchLevel(level_num).getTrScale();	float symbol_penalty = getSearchLevel(level_num).getSymbolPenalty();		// update the score with the arc score	//	GraphArc<SearchNode>* tmp_arc = curr_vert->getCurr();	long symbol_id = tmp_arc->getVertex()->getItem()->getSymbolId();	if (!getSearchLevel(level_num).isDummySymbol(symbol_id)) {	  next_instance->setScore(next_instance->getScore() + (tr_scale * tmp_arc->getWeight()) + symbol_penalty);	}	else {	  next_instance->setScore(next_instance->getScore() + tmp_arc->getWeight());	}		// update the history with the next node at this level	//	next_instance->setSymbol(context_pool_d.shiftAndAllocate(next_instance->getSymbol(), tmp_arc->getVertex()));	// add any posterior score such as n-symbol probabilities	//  	if (getSearchLevel(level_num).useNSymbol()) {	  GraphVertex<SearchNode>* central_vertex =	    next_instance->getSymbol()->getCentralVertex();	  long symbol_id = central_vertex->getItem()->getSymbolId();	  	  if (!getSearchLevel(level_num).isDummySymbol(symbol_id) &&	      !getSearchLevel(level_num).isSkipSymbol(symbol_id) &&	      !central_vertex->isStart() && !central_vertex->isTerm()) {	    shiftNSymbol(next_instance, level_num, central_vertex);	    	    float posterior_score =	      getPosteriorScore(next_instance->getNSymbol(), level_num);	    next_instance->setScore(next_instance->getScore() + posterior_score);	  }	}		// add the instance to the search node's instance list	//	if (!addHypothesisPath(next_instance, curr_instance, level_num,			       tmp_arc->getWeight())) {	  return Error::handle(name(), L"evaluateInstanceModels", Error::ARG, __FILE__, __LINE__);	}	      }            // bump the current instance off of the instance list      //      instance_lists_d(level_num).removeFirst(curr_instance);      if (curr_instance->getRefCount() < 1) {	Instance::deleteInstance(curr_instance, true);      }      instance_lists_d(level_num).gotoFirst();          } // end if the instance is active  }   // end while (!end_loop)    // exit gracefully  //  return true;  }// method: evaluateTraceModels//// arguments: (none)//// return: logical error status.//// evaluate all statistical models//boolean HierarchicalSearch::evaluateTraceModels() {  // define local variables  //  String out;  String val;  long level_num = getNumLevels() - 1;  boolean end_loop = false;  Trace* curr_trace = (Trace*)NULL;  Trace* next_trace = (Trace*)NULL;      GraphVertex<SearchNode>* curr_vert = (GraphVertex<SearchNode>*)NULL;  SearchSymbol item;    BiGraphVertex<TrainNode>* vertex = (BiGraphVertex<TrainNode>*)NULL;    // output the frame information  //  if (debug_level_d >= Integral::DETAILED) {    out.assign(L"\n-> evaluating data in frame: ");    val.assign((ullong)current_frame_d);    out.concat(val);    Console::put(out);  }  //  add for word-internal context generation  // when we are NOT in context generation mode -  //   evaluate each instance at the lowest level of the hierarchy  //  if (!context_generation_mode_d && (search_mode_d != TRAIN)) {  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -