questions about the cost calculation

243 views
Skip to first unread message

homin kwon

unread,
Jul 25, 2018, 7:10:31 PM7/25/18
to kaldi-help
Hello,

I wanted to understand how how graph and acoustic costs are calculated in the decoding process. Thus, I added the following lines highlighted by Blue to see what it prints. It looks like StateId doesn't have graph cost and acoustic cost all the times. I can see the costs per word id (i.e. 2:197174 = 16.0992,-30.9669 | 6719:198772 = 7.19654,-15.4476 | 56757:102087 = 20.1372,-41.4124). Are there any reasons not saving them all the times? If not, could help me understand how come if I am misleading? Also, I would like to understand why the graph cost comes positive. I guess the acoustic cost would be in a form of log probability but the graph cost seems to be not or continuously added somehow in the graph.

Thanks in advance,
Homin

template<class Arc, class I>
bool GetLinearSymbolSequence(const Fst<Arc> &fst,
                             vector<I> *isymbols_out,
                             vector<I> *osymbols_out,
                             typename Arc::Weight *tot_weight_out) {
  typedef typename Arc::StateId StateId;
  typedef typename Arc::Weight Weight;

  Weight tot_weight = Weight::One();
  vector<I> ilabel_seq;
  vector<I> olabel_seq;

  StateId cur_state = fst.Start();
  ...
  while (1) {
    Weight w = fst.Final(cur_state);
    if (w != Weight::Zero()) {  // is final..
    ...
    } else {
      ...
      ArcIterator<Fst<Arc> > iter(fst, cur_state);  // get the only arc.
      const Arc &arc = iter.Value();
      tot_weight = Times(arc.weight, tot_weight);
      std::cerr << arc.ilabel << ":" << arc.olabel << " = " << arc.weight << std::endl;
      ...
    }
  }
}




LOG (online2-wav-nnet3-latgen-faster[5.2.107~4-e8928]:ComputeDerivedVars():ivector-extractor.cc:183) Computing derived variables for iVector extractor
LOG (online2-wav-nnet3-latgen-faster[5.2.107~4-e8928]:ComputeDerivedVars():ivector-extractor.cc:204) Done.
LOG (online2-wav-nnet3-latgen-faster[5.2.107~4-e8928]:RemoveSomeNodes():nnet-nnet.cc:916) Removed 2 orphan nodes.
LOG (online2-wav-nnet3-latgen-faster[5.2.107~4-e8928]:RemoveOrphanComponents():nnet-nnet.cc:841) Removing 2 orphan components.
LOG (online2-wav-nnet3-latgen-faster[5.2.107~4-e8928]:Collapse():nnet-utils.cc:770) Added 1 components, removed 2
LOG (online2-wav-nnet3-latgen-faster[5.2.107~4-e8928]:CompileLooped():nnet-compile-looped.cc:336) Spent 0.211483 seconds in looped compilation.
wav-copy scp,p:/home/kwon/tiny_testset_en/PE-test_hires/split1/1/wav.scp ark:- 
LOG (wav-copy[5.2.107~4-e8928]:main():wav-copy.cc:68) Copied 1 wave files
extend-wav-with-silence ark:- ark:- 
LOG (extend-wav-with-silence[5.2.107~4-e8928]:main():extend-wav-with-silence.cc:107) Successfully extended 1 files.
2:197174 = 16.0992,-30.9669
12510:0 = 0,0
12509:0 = 0,0
12509:0 = 0,0
12509:0 = 0,0
33638:0 = 0,0
33637:0 = 0,0
31814:0 = 0,0
30492:0 = 0,0
30491:0 = 0,0
6720:0 = 0,0
6719:198772 = 7.19654,-15.4476
45504:0 = 0,0
45503:0 = 0,0
45503:0 = 0,0
45503:0 = 0,0
56758:0 = 0,0
56757:0 = 0,0
56757:102087 = 20.1372,-41.4124
18576:0 = 0,0
18575:0 = 0,0
18575:0 = 0,0
2:0 = 0,0
43656:0 = 0,0
43655:0 = 0,0
43655:0 = 0,0
22602:0 = 0,0

Daniel Povey

unread,
Jul 25, 2018, 7:48:11 PM7/25/18
to kaldi-help
It has to do with how lattices are determinized; this pushes the costs around, but the sum along any path from initial state to final state will be the same.


--
Go to http://kaldi-asr.org/forums.html find out how to join
---
You received this message because you are subscribed to the Google Groups "kaldi-help" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kaldi-help+unsubscribe@googlegroups.com.
To post to this group, send email to kaldi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kaldi-help/46def955-6315-48ed-a9ef-eb669307d9b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rudolf A. Braun

unread,
Jul 27, 2018, 10:23:38 AM7/27/18
to kaldi-help
That will happen for all CompactLattices right? I'm guessing this means it is impossible to revert the pushing and find out from a CompactLattice what the, for example, actual graph costs for each word are?
To unsubscribe from this group and stop receiving emails from it, send an email to kaldi-help+...@googlegroups.com.

Daniel Povey

unread,
Jul 27, 2018, 1:45:23 PM7/27/18
to kaldi-help, Vimal Manohar
Yes, it's impossible.  
In one of our discriminative training setups (which I'm not sure is committed yet) we need the scores to be in the right place, so we get around this by having the decoder write lattices without determinization (--determinize-lattice=false) and then piping it into lattice-determinize-phone-pruned with the option --write-compact=false, which makes sure to keep the graph costs in the 'right place'.  It writes it in the non-compact format though.
In the vast majority of use cases, you don't need the scores to be in the right place and pushing won't affect the result.

Dan

To unsubscribe from this group and stop receiving emails from it, send an email to kaldi-help+unsubscribe@googlegroups.com.

To post to this group, send email to kaldi...@googlegroups.com.

homin kwon

unread,
Jul 27, 2018, 2:24:21 PM7/27/18
to kaldi-help
Thanks for detailed explanations as always!

Best,
Homin
Reply all
Reply to author
Forward
0 new messages