graykode / nlp-tutorial

Natural Language Processing Tutorial for Deep Learning Researchers
https://www.reddit.com/r/MachineLearning/comments/amfinl/project_nlptutoral_repository_who_is_studying/
MIT License
14.31k stars 3.95k forks source link

BERT-Torch.py may have a small mistake #56

Closed lucenzhong closed 4 years ago

lucenzhong commented 4 years ago

line 69-70 : index = randint(0, vocab_size - 1) # random index in vocabulary input_ids[pos] = word_dict[number_dict[index]] The length of number_dict is 25, but the length of vocab_size is 29, so number_dict[index] might be out of range. May be we should change line 69 into index = randint(0, len(word_list) - 1)?