]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/kaldi.git/commitdiff
chain branch: merging upstream/master
authorDaniel Povey <dpovey@gmail.com>
Tue, 3 Nov 2015 05:01:59 +0000 (00:01 -0500)
committerDaniel Povey <dpovey@gmail.com>
Tue, 3 Nov 2015 05:01:59 +0000 (00:01 -0500)
1  2 
egs/wsj/s5/local/nnet3/run_tdnn_baseline.sh
egs/wsj/s5/steps/nnet3/lstm/train.sh
src/fstext/determinize-star-inl.h
src/hmm/hmm-topology-test.cc
src/hmm/hmm-topology.cc
src/hmm/hmm-topology.h
src/hmm/hmm-utils-test.cc
src/nnet3/nnet-test-utils.cc
src/nnet3bin/nnet3-merge-egs.cc
src/nnet3bin/nnet3-shuffle-egs.cc
src/tree/context-dep.cc

Simple merge
Simple merge
index 3b1e0bc769ff8c8fdbde7847808dfee0b78410c2,a866e8ac423b60f2e81040d73c856b8881a071fe..61cf13e17bc5c6c151dde350df15bc95bee7fb67
@@@ -58,11 -60,12 +60,14 @@@ void TestHmmTopology() 
  
    HmmTopology topo;
  
-   std::istringstream iss(input_str);
-   topo.Read(iss, false);
-   KALDI_ASSERT(topo.MinLength(3) == 3);
-   KALDI_ASSERT(topo.MinLength(11) == 2);
+   if (RandInt(0, 1) == 0) {
+     topo = GenRandTopology();
+   } else {
+     std::istringstream iss(input_str);
+     topo.Read(iss, false);
++    KALDI_ASSERT(topo.MinLength(3) == 3);
++    KALDI_ASSERT(topo.MinLength(11) == 2);
+   }
  
    std::ostringstream oss;
    topo.Write(oss, binary);
index cafec65f061e2efe9f3184c07c3bf82e277af119,bcfef6457a788cfafd849b5cb8b7a581c6b68908..3c88f9342a093d66d4576464dceecc96089cf0fd
@@@ -290,78 -291,6 +291,77 @@@ int32 HmmTopology::NumPdfClasses(int32 
    return max_pdf_class+1;
  }
  
 +int32 HmmTopology::MinLength(int32 phone) const {
 +  const TopologyEntry &entry = TopologyForPhone(phone);
 +  // min_length[state] gives the minimum length for sequences up to and
 +  // including that state.
 +  std::vector<int32> min_length(entry.size(),
 +                                std::numeric_limits<int32>::max());
 +  KALDI_ASSERT(!entry.empty());
 +
 +  min_length[0] = (entry[0].pdf_class == -1 ? 0 : 1);
 +  int32 num_states = min_length.size();
 +  bool changed = true;
 +  while (changed) {
 +    changed = false;
 +    for (int32 s = 0; s < num_states; s++) {
 +      const HmmState &this_state = entry[s];
 +      std::vector<std::pair<int32, BaseFloat> >::const_iterator
 +          iter = this_state.transitions.begin(),
 +          end = this_state.transitions.end();
 +      for (; iter != end; ++iter) {
 +        int32 next_state = iter->first;
 +        KALDI_ASSERT(next_state < num_states);
 +        int32 next_state_min_length = min_length[s] +
 +            (entry[next_state].pdf_class == -1 ? 0 : 1);
 +        if (next_state_min_length < min_length[next_state]) {
 +          min_length[next_state] = next_state_min_length;
 +          if (next_state < s)
 +            changed = true;
 +          // the test of 'next_state < s' is an optimization for speed.
 +        }
 +      }
 +    }
 +  }
 +  KALDI_ASSERT(min_length.back() != std::numeric_limits<int32>::max());
 +  // the last state is the final-state.
 +  return min_length.back();
 +}
 +
 +HmmTopology GetDefaultTopology(const std::vector<int32> &phones_in) {
 +  std::vector<int32> phones(phones_in);
 +  std::sort(phones.begin(), phones.end());
 +  KALDI_ASSERT(IsSortedAndUniq(phones) && !phones.empty());
 +
 +  std::ostringstream topo_string;
 +  topo_string <<  "<Topology>\n"
 +      "<TopologyEntry>\n"
 +      "<ForPhones> ";
 +  for (size_t i = 0; i < phones.size(); i++)
 +    topo_string << phones[i] << " ";
  
 +  topo_string << "</ForPhones>\n"
 +      "<State> 0 <PdfClass> 0\n"
 +      "<Transition> 0 0.5\n"
 +      "<Transition> 1 0.5\n"
 +      "</State> \n"
 +      "<State> 1 <PdfClass> 1 \n"
 +      "<Transition> 1 0.5\n"
 +      "<Transition> 2 0.5\n"
 +      "</State>  \n"
 +      " <State> 2 <PdfClass> 2\n"
 +      " <Transition> 2 0.5\n"
 +      " <Transition> 3 0.5\n"
 +      " </State>   \n"
 +      " <State> 3 </State>\n"
 +      " </TopologyEntry>\n"
 +      " </Topology>\n";
 +
 +  HmmTopology topo;
 +  std::istringstream iss(topo_string.str());
 +  topo.Read(iss, false);
 +  return topo;
 +
 +}
  
  } // End namespace kaldi
Simple merge
index 6f1267646d8d6d4441fa321ab4200acefc1715c4,828dba9fa7b002502ef3da75174caf8a30c8c6aa..07ad94b599253d74c78676b615b9d9d4f0917c29
@@@ -19,7 -19,7 +19,8 @@@
  // limitations under the License.
  
  #include "hmm/hmm-utils.h"
 +#include "hmm/tree-accu.h"
+ #include "hmm/hmm-test-utils.h"
  
  namespace kaldi {
  
@@@ -182,35 -182,43 +183,66 @@@ void TestConvertPhnxToProns() 
                                      word_end_sym, &ans)
                   && ans == ans_check);
    }
++<<<<<<< HEAD
 +}
 +
 +void TestAccumulateTreeStatsOptions() {
 +  AccumulateTreeStatsOptions opts;
 +  opts.var_floor = RandInt(0, 10);
 +  opts.ci_phones_str = "3:2:1";
 +  opts.phone_map_rxfilename = "echo 1 2; echo 2 5 |";
 +  opts.collapse_pdf_classes = (RandInt(0, 1) == 0);
 +  opts.context_width = RandInt(3, 4);
 +  opts.central_position = RandInt(0, 2);
 +  AccumulateTreeStatsInfo info(opts);
 +  KALDI_ASSERT(info.var_floor == opts.var_floor);
 +  KALDI_ASSERT(info.ci_phones.size() == 3 && info.ci_phones[2] == 3);
 +  KALDI_ASSERT(info.phone_map.size() == 3 && info.phone_map[2] == 5);
 +  KALDI_ASSERT(info.context_width == opts.context_width);
 +  KALDI_ASSERT(info.central_position == opts.central_position);
  }
  
+ void TestSplitToPhones() {
+   ContextDependency *ctx_dep;
+   TransitionModel *trans_model = GenRandTransitionModel(&ctx_dep);
+   std::vector<int32> phone_seq;
+   int32 num_phones = RandInt(0, 10);
+   const std::vector<int32> &phone_list = trans_model->GetPhones();
+   for (int32 i = 0; i < num_phones; i++) {
+     int32 rand_phone = phone_list[RandInt(0, phone_list.size() - 1)];
+     phone_seq.push_back(rand_phone);
+   }
+   bool reorder = (RandInt(0, 1) == 0);
+   std::vector<int32> alignment;
+   GenerateRandomAlignment(*ctx_dep, *trans_model, reorder,
+                           phone_seq, &alignment);
+   std::vector<std::vector<int32> > split_alignment;
+   SplitToPhones(*trans_model, alignment, &split_alignment);
+   KALDI_ASSERT(split_alignment.size() == phone_seq.size());
+   for (size_t i = 0; i < split_alignment.size(); i++) {
+     KALDI_ASSERT(!split_alignment[i].empty());
+     for (size_t j = 0; j < split_alignment[i].size(); j++) {
+       int32 transition_id = split_alignment[i][j];
+       KALDI_ASSERT(trans_model->TransitionIdToPhone(transition_id) ==
+                    phone_seq[i]);
+     }
+   }
+   delete trans_model;
+   delete ctx_dep;
+ }
  
 +
 +
 +
  }
  
  int main() {
    kaldi::TestConvertPhnxToProns();
 +#ifndef _MSC_VER
 +  kaldi::TestAccumulateTreeStatsOptions();
 +#endif
+   for (int32 i = 0; i < 2; i++)
+     kaldi::TestSplitToPhones();
    std::cout << "Test OK.\n";
  }
  
Simple merge
Simple merge
Simple merge
Simple merge