Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions egs/wsj/s5/steps/nnet3/chain/gen_topo5.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

# Copyright 2012 Johns Hopkins University (author: Daniel Povey)

# This script was modified around 11.11.2016, when the code was extended to
# support having a different pdf-class on the self loop.

# Generate a topology file. This allows control of the number of states in the
# non-silence HMMs, and in the silence HMMs. This is a modified version of
# 'utils/gen_topo.pl' that generates a different type of topology, one that we
Expand Down Expand Up @@ -29,22 +32,17 @@
nonsilence_phones = [ int(x) for x in args.nonsilence_phones.split(":") ]
all_phones = silence_phones + nonsilence_phones


print("<Topology>")
print("<TopologyEntry>")
print("<ForPhones>")
print(" ".join([str(x) for x in all_phones]))
print("</ForPhones>")
# state 0 is nonemitting
print("<State> 0 <Transition> 1 0.5 <Transition> 2 0.5 </State>")
# state 1 is for when we traverse it in 1 state
print("<State> 1 <PdfClass> 0 <Transition> 4 1.0 </State>")
# state 2 is for when we traverse it in >1 state, for the first state.
print("<State> 2 <PdfClass> 2 <Transition> 3 1.0 </State>")
# state 3 is for the self-loop. Use pdf-class 1 here so that the default
# phone-class clustering (which uses only pdf-class 1 by default) gets only
# stats from longer phones.
print("<State> 3 <PdfClass> 1 <Transition> 3 0.5 <Transition> 4 0.5 </State>")
print("<State> 4 </State>")
print("0 1 1 0.69314718055")
print("0 2 3 0.69314718055")
print("1 1 2 0.69314718055")
print("1 0.69314718055")
print("2 0.0")
print("")
print("</TopologyEntry>")
print("</Topology>")

3 changes: 2 additions & 1 deletion src/fstext/fstext-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ void MakePrecedingInputSymbolsSame(bool start_is_epsilon, MutableFst<Arc> *fst);


/// As MakePrecedingInputSymbolsSame, but takes a functor object that maps
/// labels to (int32) classes
/// labels to (int32) classes. Caution: it must not map kNoLabel (-1)
/// to the same value as any real symbol.
template<class Arc, class F>
void MakePrecedingInputSymbolsSameClass(bool start_is_epsilon, MutableFst<Arc> *fst, const F &f);

Expand Down
5 changes: 3 additions & 2 deletions src/hmm/hmm-utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,8 @@ class TidToSelfLoopMapper {

// This maps valid transition-ids to transition states, and maps all other
// symbols (i.e. epsilon symbols, disambig symbols, and symbols with values
// over 100000/kNontermBigNumber) to zero. Its point is to provide an
// over 100000/kNontermBigNumber) to zero. (and -1 == kNoLabel to -1).
// Its purpose is to provide an
// equivalence class on labels that's relevant to what the self-loop will be
// on the following state.
TidToSelfLoopMapper(const Transitions &trans_model,
Expand All @@ -397,7 +398,7 @@ class TidToSelfLoopMapper {
KALDI_ERR << "AddSelfLoops: graph already has self-loops.";
return trans_model_.InfoForTransitionId(tid).self_loop_transition_id;
} else if (tid == fst::kNoLabel) {
return 0;
return -1;
} else { // 0 or (presumably) disambiguation symbol. Map to zero
int32 big_number = fst::kNontermBigNumber; // 1000000
if (tid != 0 && tid < big_number) {
Expand Down