INNER CODE UNIT · Python
word_dropout
yuhaozhang/tacred-relation · data/loader.py:131
def word_dropout(tokens, dropout):
""" Randomly dropout tokens (IDs) and replace them with <UNK> tokens. """
return [constant.UNK_ID if x != constant.UNK_ID and np.random.random() < dropout \
else x for x in tokens]