aimagelab/show-control-and-tell

RuntimeError: view size is not compatible with input tensor's size and stride

cws7777 opened this issue · 1 comments

Hi,
I'm trying to run the code with the command like below,
python test_region_sequence.py --dataset coco --exp_name ours --sample_rl_nw
and
python test_region_set.py --dataset coco --exp_name ours --sample_rl_nw
, which are COCO Entities with CIDEr + NW optimization.

However, both give me same error like below,
Traceback (most recent call last): File "test_region_sequence.py", line 138, in <module> out, _ = model.beam_search((detections_i, ctrl_det_seqs_test_unique), eos_idxs=[text_field.vocab.stoi['<eos>'], -1], beam_size=5) File "/home/tejasrii/show_control_tell/models/CaptioningModel.py", line 151, in beam_search selected_logprob, selected_idx = torch.sort(seq_logprob.view(b_s, -1), -1, descending=True) RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.

What should I do here..?

Thank you for sharing the code! :)
and Hope be safe from COVID-19.

Figured out with changing ".view()" to ".reshape" in line 151 CaptioningModel.py