a-PyTorch-Tutorial-to-Image-Captioning icon indicating copy to clipboard operation
a-PyTorch-Tutorial-to-Image-Captioning copied to clipboard

ValueError: max() arg is an empty sequence

Open loserlulin9 opened this issue 2 years ago • 3 comments

I encounter with a bug which is "ValueError: max() arg is an empty sequence" when I run caption.py. I find that the parameter complete_inds and complete_seqs_scores is null during the process. Is this due to my checkpoint model? Could anyone help me? Thanks!!! image

loserlulin9 avatar Feb 15 '23 09:02 loserlulin9

Well, it's empty, so there are no complete sequences. You could catch it with an if to add the last incomplete sequence:

if len(complete_seqs) == 0:
   complete_seqs.extend(seqs.tolist())  # (s, step+1)
   complete_seqs_alpha.extend(seqs_alpha.tolist())
   complete_seqs_scores.extend(top_k_scores.tolist())  # (s)

That did it for me

AndreiMoraru123 avatar Feb 15 '23 11:02 AndreiMoraru123

Thank u so much! It works! Wish u have a nice day!

Well, it's empty, so there are no complete sequences. You could catch it with an if to add the last incomplete sequence:

if len(complete_seqs) == 0:
   complete_seqs.extend(seqs.tolist())  # (s, step+1)
   complete_seqs_alpha.extend(seqs_alpha.tolist())
   complete_seqs_scores.extend(top_k_scores.tolist())  # (s)

That did it for me

loserlulin9 avatar Feb 15 '23 12:02 loserlulin9

I also,but not solve it

tigerbrother222 avatar Aug 03 '23 04:08 tigerbrother222