meshed-memory-transformer icon indicating copy to clipboard operation
meshed-memory-transformer copied to clipboard

variance dtype issue

Open Bueno1887 opened this issue 4 years ago • 7 comments

Traceback (most recent call last): File "test.py", line 77, in scores = predict_captions(model, dict_dataloader_test, text_field) File "test.py", line 26, in predict_captions out, _ = model.beam_search(images, 20, text_field.vocab.stoi[''], 5) File "/home/mingjie/meshed-memory-transformer/models/captioning_model.py", line 70, in beam_search return bs.apply(visual, out_size, return_probs, **kwargs) File "/home/mingjie/meshed-memory-transformer/models/beam_search/beam_search.py", line 71, in apply visual, outputs = self.iter(t, visual, outputs, return_probs, **kwargs) File "/home/mingjie/meshed-memory-transformer/models/beam_search/beam_search.py", line 121, in iter self.model.apply_to_states(self._expand_state(selected_beam, cur_beam_size)) File "/home/mingjie/meshed-memory-transformer/models/containers.py", line 30, in apply_to_states self._buffers[name] = fn(self._buffers[name]) File "/home/mingjie/meshed-memory-transformer/models/beam_search/beam_search.py", line 27, in fn beam.expand(*([self.b_s, self.beam_size] + shape[1:]))) RuntimeError: gather_out_cuda(): Expected dtype int64 for index

When I try to evaluate your model, it came up to that....and I don't know how to fix that.. Would you please give me some tips?

Bueno1887 avatar Nov 02 '20 06:11 Bueno1887

I also got this problem, try pytorch==1.1.0 may help.

Cranooooooo avatar Nov 08 '20 11:11 Cranooooooo

Thanks a lot:) It works @Cranooooooo

Bueno1887 avatar Nov 09 '20 13:11 Bueno1887

I have the same issues but i can't install torch==1.1.0 because I use cuda 11.2. There is a fix with torch 1.6 or 1.7 ?

marcomameli1992 avatar Jan 07 '21 15:01 marcomameli1992

I have the same issues but i can't install torch==1.1.0 because I use cuda 11.2. There is a fix with torch 1.6 or 1.7 ?

You can modify a line of code(line 118):selected_beam = selected_idx / /candidate_logprob.shape[-1] meshed-memory-transformer/models/beam_search/beam_search.py which can address this problem.

ppengzeng avatar Jan 16 '21 03:01 ppengzeng

I have the same issues but i can't install torch==1.1.0 because I use cuda 11.2. There is a fix with torch 1.6 or 1.7 ?

You can modify a line of code(line 118):selected_beam = selected_idx / /candidate_logprob.shape[-1] meshed-memory-transformer/models/beam_search/beam_search.py which can address this problem.

I modified the code according to the above, but a new problem appeared, Would you please give me some tips?

Traceback (most recent call last): File "test.py", line 77, in scores = predict_captions(model, dict_dataloader_test, text_field) File "test.py", line 36, in predict_captions scores, _ = evaluation.compute_scores(gts, gen) File "/home/bwh/python/meshed-memory-transformer-master/evaluation/init.py", line 13, in compute_scores score, scores = metric.compute_score(gts, gen) File "/home/bwh/python/meshed-memory-transformer-master/evaluation/meteor/meteor.py", line 46, in compute_score stat = self._stat(res[i][0], gts[i]) File "/home/bwh/python/meshed-memory-transformer-master/evaluation/meteor/meteor.py", line 63, in _stat self.meteor_p.stdin.flush() BrokenPipeError: [Errno 32] Broken pipe

Baixiaobai201619707 avatar Sep 15 '21 13:09 Baixiaobai201619707

I have solved this issue:

this is a bug, please fix the code in models/beam_search.py line 118:

    # selected_beam = selected_idx / candidate_logprob.shape[-1]
    selected_beam = torch.div(selected_idx, candidate_logprob.shape[-1], rounding_mode="floor")  

linhuixiao avatar Jul 22 '22 08:07 linhuixiao

I have solved this issue:

this is a bug, please fix the code in models/beam_search.py line 118:

    # selected_beam = selected_idx / candidate_logprob.shape[-1]
    selected_beam = torch.div(selected_idx, candidate_logprob.shape[-1], rounding_mode="floor")  

I made changes, but the code still reports an error.

Evaluation: 100%|█████████████████████████████| 500/500 [02:11<00:00, 3.88it/s] Traceback (most recent call last): File "test.py", line 77, in scores = predict_captions(model, dict_dataloader_test, text_field) File "test.py", line 36, in predict_captions scores, _ = evaluation.compute_scores(gts, gen) File "/home/jiejie/文档/pytorch/meshed/evaluation/init.py", line 16, in compute_scores score, scores = metric.compute_score(gts, gen) File "/home/jiejie/文档/pytorch/meshed/evaluation/meteor/meteor.py", line 45, in compute_score stat = self._stat(res[i][0], gts[i]) File "/home/jiejie/文档/pytorch/meshed/evaluation/meteor/meteor.py", line 62, in _stat self.meteor_p.stdin.flush() BrokenPipeError: [Errno 32] 断开的管道

775266553 avatar Mar 15 '24 08:03 775266553