Cadene / Cadene/vqa.pytorch

Left padding when encoding questions

Open
#39 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
733
Forks
176
PR merge metrics
No merged PRs in 30d

Description

In vqa_processed.py, encode_question fails (index out of range) when the padding desired is 'left' and the question length is larger than the maximum length.

A possible fix is to replace the else branch :
```
else: #['pad'] == 'left'
new_k = k + maxlength - len(ex['question_words_UNK'])
ex['question_wids'][new_k] = word_to_wid[w]
ex['seq_length'] = len(ex['question_words_UNK'])
```

With

```
else: # ['pad'] == 'left'
if maxlength < len(ex['question_words_UNK']):
ex['question_wids'][k] = word_to_id[w]
else:
new_k = k + maxlength - len(ex['question_words_UNK'])
ex['question_wids'][new_k] = word_to_id[w]
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.