tensorflow / nmt

TensorFlow Neural Machine Translation Tutorial
Apache License 2.0
6.39k stars 1.96k forks source link

Hello,i have some question about beam search #66

Open yqtaowhu opened 7 years ago

yqtaowhu commented 7 years ago

when i set beam_width =2,and in moder.py i change if beam_width > 0: logits = outputs.beam_search_decder_output sample_id = outputs.predicted_id this but i get the logits shape is [3,53,10,2] when i decoder 10 sentence i dont know why the first dim is 3 not vocabulary_size. when i set beam_width=0 the logit shape is [50,10,17191] is can easy understand hope can reply!

piyank22 commented 7 years ago

outputs.beam_search_decoder_output is a tuple of three things namely ( scores , predicted_ids , parent_ids )

53 must be time_axis of decoder 10 is the number of sentence 2 is the beam_width

change : logits = outputs.beam_search_decoder_output.scores

yqtaowhu commented 7 years ago

@piyank22 thank you very much!

johnsonice commented 7 years ago

@piyank22 Thanks for you explanation! I just have a follow up question, is there a way that we can find out best prediction amount all results?

in the repo, it seem set beam_id to be 0 as default. I can't find explanation anywhere in the documentation.

piyank22 commented 7 years ago

beam_id : 0 , implies that no beam search is being used , greedy inference helper is being used.