j-min / tf_tutorial_plus

Tutorials for TensorFlow APIs the official documentation doesn't cover
290 stars 98 forks source link

Problem with TrainingHelper's parameter sequence length #3

Open yangshao opened 7 years ago

yangshao commented 7 years ago

hi, I'm trying to implement a seq2seq model. when I use the actual sequence length as TrainingHelper's parameter, I get an error for the loss calculation: InvalidArgumentError (see above for traceback): logits and labels must have the same first dimension, got logits shape [960,15038] and labels shape [1280] But if I use all the same sequence length, the code works fine. what's the effects of using actual sequence length instead of using max sequence length?

jihopark commented 7 years ago

i've got a similar problem. i think the decoder is sometimes outputting logits of shorter length than the max seq length.

yangshao commented 6 years ago

@jihopark do you solve this problem?

j-min commented 6 years ago

Did you check arguments of tf.contrib.seq2seq.dynamic_decode as below? impute_finished = True maximum_sequence_length=dec_sentence_length (int, maximum length of current batch)

tf.contrib.seq2seq.dynamic_decode(
                    inference_decoder,
                    output_time_major=False,
                    impute_finished=True,
                    maximum_iterations=dec_sentence_length)
yangshao commented 6 years ago

yes,i checked it. besides, do you know howto do beam search in tf 1.1.0? thanks

On Jul 14, 2017 11:05 PM, "Jaemin Cho" notifications@github.com wrote:

Did you check argument when you use seq2seq.dynamic_decode as below? impute_finished = True maximum_sequence_length=dec_sentence_length (int, maximum length of current batch)

tf.contrib.seq2seq.dynamic_decode( inference_decoder, output_time_major=False, impute_finished=True, maximum_iterations=dec_sentence_length)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_j-2Dmin_tf-5Ftutorial-5Fplus_issues_3-23issuecomment-2D315512691&d=DwMFaQ&c=nE__W8dFE-shTxStwXtp0A&r=DiIBuPIqwiFvAlEP96lTDsm5KO-dALrQHN3g3Uq_3PU&m=fonToKOqCkR0kVGIE-C_3MKVbH2vEUtey3B8BObSAl8&s=-60bNgzNgEmxIQ2xPqTFRhqdlE4kGdS5CI19waor_XU&e=, or mute the thread https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AIBBiqgIYrpKco0IGbCTyUcdRepZKJ0yks5sOFaKgaJpZM4OR-2DFw&d=DwMFaQ&c=nE__W8dFE-shTxStwXtp0A&r=DiIBuPIqwiFvAlEP96lTDsm5KO-dALrQHN3g3Uq_3PU&m=fonToKOqCkR0kVGIE-C_3MKVbH2vEUtey3B8BObSAl8&s=kC4qxBrmQIeD79W9wsHShl62_vzRkLNy5jHuE0IHztA&e= .