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

Question about random sampling. #13

Closed
SongRb opened this issue Oct 20, 2018 · 3 comments
Closed

Question about random sampling. #13

SongRb opened this issue Oct 20, 2018 · 3 comments

Comments

@SongRb
Copy link

SongRb commented Oct 20, 2018

prob = random.random()
if prob < 0.15:
# 80% randomly change token to make token
if prob < prob * 0.8:
tokens[i] = self.vocab.mask_index
# 10% randomly change token to random token
elif prob * 0.8 <= prob < prob * 0.9:
tokens[i] = random.randrange(len(self.vocab))
# 10% randomly change token to current token
elif prob >= prob * 0.9:
tokens[i] = self.vocab.stoi.get(token, self.vocab.unk_index)
output_label.append(self.vocab.stoi.get(token, self.vocab.unk_index))

Well, seems random.random() always returns a positive number, so prob >= prob * 0.9 will always be true?

@codertimo
Copy link
Owner

Haha your right it seems else is more efficient. thank you for your comment 👀

codertimo added a commit that referenced this issue Oct 20, 2018
@leon-cas
Copy link

if prob < prob * 0.8: always False?
elif prob * 0.8 <= prob < prob * 0.9: always False?

artemisart added a commit to artemisart/BERT-pytorch that referenced this issue Oct 22, 2018
@artemisart
Copy link
Contributor

I also think these conditions are still wrong, I'm sending a PR

codertimo added a commit that referenced this issue Oct 23, 2018
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

4 participants