cmusphinx / g2p-seq2seq

G2P with Tensorflow
Other
667 stars 196 forks source link

show probability score in beam mode #157

Open huangruizhe opened 5 years ago

huangruizhe commented 5 years ago

When we list top N (N>1) variants of decoding in the --return_beams mode, can we have a probability score for each variant? It seems there is no such an option. Thanks!

jubang0219 commented 5 years ago

I want it too. But, I could not find that option.

So, I added the following variable in line 448 of g2p_seq2seq/g2p.py.

_output_scores = np.split(result["scores"], self.decode_hp.beamsize, axis=0)

And then, print the score of each candidate.

_print("%s %s (%.4f)%s" % (decoded_inputs, decoded_outputs, np.exp(output_scores[k]), self.decodehp.delimiter))

I think the output scores are logprob, so I used the np.exp() function. (It is not clear whether the logprob is correct. )

Thanks!