Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Left padding when encoding questions #39

Open
DenisDsh opened this issue Jul 23, 2018 · 0 comments
Open

Left padding when encoding questions #39

DenisDsh opened this issue Jul 23, 2018 · 0 comments

Comments

@DenisDsh
Copy link

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]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant