summary_loop icon indicating copy to clipboard operation
summary_loop copied to clipboard

IndexError when decode with beam_size > 1

Open s103321048 opened this issue 5 years ago • 2 comments

Followed the instruction from here and changed the beam_size to more than 1. IndexError occur:

~/summary_loop/model_generator.py in decode(self, bodies, max_output_length, max_batch_size, beam_size, return_scores, sample, progress)
    232             with torch.no_grad():
    233                 if beam_size > 1:
--> 234                     batch_outputs = self.decode_beam_batch(batch_bodies, beam_size=beam_size, max_output_length=max_output_length, sample=sample)
    235                 else:
    236                     batch_outputs = self.decode_batch(batch_bodies, max_output_length=max_output_length, sample=sample, return_scores=return_scores)

~/summary_loop/model_generator.py in decode_beam_batch(self, bodies, beam_size, max_output_length, sample)
    200             if build_up is not None:
    201                 build_up = build_up[tracks, :]
--> 202             past = [p[:, tracks, :] for p in past]
    203 
    204             # Update the latest scores, and the current_build

~/summary_loop/model_generator.py in <listcomp>(.0)
    200             if build_up is not None:
    201                 build_up = build_up[tracks, :]
--> 202             past = [p[:, tracks, :] for p in past]
    203 
    204             # Update the latest scores, and the current_build

IndexError: tensors used as indices must be long, byte or bool tensors

s103321048 avatar Mar 28 '21 09:03 s103321048

Add the following line at 191 in model_generator.py

tracks = list(tracks)

s103321048 avatar Mar 31 '21 01:03 s103321048

I have fixed this error as well. The tracks tensor was being interpreted as a float instead of a long, which was causing trouble. Thanks for catching it!

tingofurro avatar Jun 11 '21 20:06 tingofurro