keras-team / keras-nlp

Modular Natural Language Processing workflows with Keras
Apache License 2.0
740 stars 218 forks source link

TypeError: 'retval_' must have the same nested structure in the main and else branches:The two structures don't have the same nested structure while doing english to spanish language translation #772

Open Alwaysadil opened 1 year ago

Alwaysadil commented 1 year ago

Describe the bug

To Reproduce

Expected behavior

Additional context

Would you like to help us fix it?

abheesht17 commented 1 year ago

@Alwaysadil - please share a Colab notebook where you have reproduced this issue. Also, the notebook I shared used beam search and was working fine: https://colab.research.google.com/drive/1jtIRbIt0xqN-yqlfNUwlKAeavg4OO0WT?usp=sharing.

Alwaysadil commented 1 year ago

@abheesht17 sir, check this colab link https://colab.research.google.com/drive/13bSJlkDouDWdx8hN8B4W8PcZ0gWnL7Rn#scrollTo=dMeMMd1BK6TE

Alwaysadil commented 1 year ago

@abheesht17 Sir, please give me one reply about this issue

Alwaysadil commented 1 year ago

@abheesht17 Sir,without (@tf.function(input_signature=[tf.TensorSpec(shape=[1,40], dtype=tf.float32)])) signature getting output of beam search ,but with signature getting this nested structures mismatch error please tell me how to resolve this issue please ... https://colab.research.google.com/drive/13bSJlkDouDWdx8hN8B4W8PcZ0gWnL7Rn#scrollTo=dMeMMd1BK6TE

abheesht17 commented 1 year ago

Hey, @Alwaysadil! Sorry for not seeing your message earlier, I'm a bit preoccupied with work. But will go through your issue ASAP.

atharvapurdue commented 1 year ago

Hi @Alwaysadil , it looks like the error message indicates that the retval_ variable returned by the main and else branches of the beam_search function have different nested structures. Specifically, the first structure is a tensor of shape (1, 40) and the second structure is a tuple of two tensors of shapes (40,) and (1, 2, 40) respectively. The beam_search function expects the same nested structure in both the main and else branches.

I think modifying the modified the token_probability_fn function to return a tuple of two tensors should solve the issue. Let me know if it does not!

Alwaysadil commented 1 year ago

@atharvapurdue getting errors when modifying the token_probability_fnc to return a tuple of two tensors as the function's output type."

Alwaysadil commented 1 year ago

@abheesht17 Sir,I understood you're busy with work, so take your time going through my issue. Thank you for your response sir,waiting for ur reply @abheesht17 sir....

atharvapurdue commented 1 year ago

@atharvapurdue getting errors when modifying the token_probability_fnc to return a tuple of two tensors as the function's output type."

Hi @Alwaysadil . Could you share the colab file please? I will take a look. Thanks!

Alwaysadil commented 1 year ago

Tq @atharvapurdue for your response ,please check this colab link https://colab.research.google.com/drive/13bSJlkDouDWdx8hN8B4W8PcZ0gWnL7Rn#scrollTo=dMeMMd1BK6TE

Alwaysadil commented 1 year ago

@abheesht17 Sir, did you go through my issue? Please give me a reply sir, please......