author | Daniel Povey <dpovey@gmail.com> | |
Tue, 3 Nov 2015 05:01:59 +0000 (00:01 -0500) | ||
committer | Daniel 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 | patch | | diff1 | | diff2 | | blob | history |
egs/wsj/s5/steps/nnet3/lstm/train.sh | patch | | diff1 | | diff2 | | blob | history |
src/fstext/determinize-star-inl.h | patch | | diff1 | | diff2 | | blob | history |
src/hmm/hmm-topology-test.cc | patch | | diff1 | | diff2 | | blob | history |
src/hmm/hmm-topology.cc | patch | | diff1 | | diff2 | | blob | history |
src/hmm/hmm-topology.h | patch | | diff1 | | diff2 | | blob | history |
src/hmm/hmm-utils-test.cc | patch | | diff1 | | diff2 | | blob | history |
src/nnet3/nnet-test-utils.cc | patch | | diff1 | | diff2 | | blob | history |
src/nnet3bin/nnet3-merge-egs.cc | patch | | diff1 | | diff2 | | blob | history |
src/nnet3bin/nnet3-shuffle-egs.cc | patch | | diff1 | | diff2 | | blob | history |
src/tree/context-dep.cc | patch | | diff1 | | diff2 | | blob | history |
Simple merge
diff --cc egs/wsj/s5/steps/nnet3/lstm/train.sh
Simple merge
diff --cc src/fstext/determinize-star-inl.h
Simple merge
diff --cc src/hmm/hmm-topology-test.cc
index 3b1e0bc769ff8c8fdbde7847808dfee0b78410c2,a866e8ac423b60f2e81040d73c856b8881a071fe..61cf13e17bc5c6c151dde350df15bc95bee7fb67
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);
diff --cc src/hmm/hmm-topology.cc
index cafec65f061e2efe9f3184c07c3bf82e277af119,bcfef6457a788cfafd849b5cb8b7a581c6b68908..3c88f9342a093d66d4576464dceecc96089cf0fd
+++ b/src/hmm/hmm-topology.cc
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
diff --cc src/hmm/hmm-topology.h
Simple merge
diff --cc src/hmm/hmm-utils-test.cc
index 6f1267646d8d6d4441fa321ab4200acefc1715c4,828dba9fa7b002502ef3da75174caf8a30c8c6aa..07ad94b599253d74c78676b615b9d9d4f0917c29
// limitations under the License.
#include "hmm/hmm-utils.h"
+#include "hmm/tree-accu.h"
+ #include "hmm/hmm-test-utils.h"
namespace kaldi {
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";
}
diff --cc src/nnet3/nnet-test-utils.cc
Simple merge
diff --cc src/nnet3bin/nnet3-merge-egs.cc
Simple merge
diff --cc src/nnet3bin/nnet3-shuffle-egs.cc
Simple merge
diff --cc src/tree/context-dep.cc
Simple merge