Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

[BUGFIX] fix valid candidates issue #1323

Merged
merged 3 commits into from
Sep 1, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions scripts/pretraining/pretraining_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,16 +499,16 @@ def dynamic_masking(self, F, input_ids, valid_lengths):

for ignore_token in ignore_tokens:
# TODO(zheyuye), Update when operation += supported
valid_candidates = valid_candidates + \
valid_candidates = valid_candidates * \
F.np.not_equal(input_ids, ignore_token)
valid_lengths = valid_lengths.astype(np.float32)
valid_candidates = valid_candidates.astype(np.float32)
num_masked_position = F.np.maximum(
1, F.np.minimum(N, round(valid_lengths * self._mask_prob)))

# Get the masking probability of each position
sample_probs = F.npx.softmax(
self._proposal_distribution * valid_candidates, axis=-1) # (B, L)
sample_probs = self._proposal_distribution * valid_candidates
sample_probs /= np.sum(sample_probs, axis=-1, keepdims=True)
liuzh47 marked this conversation as resolved.
Show resolved Hide resolved
sample_probs = F.npx.stop_gradient(sample_probs)
gumbels = F.np.random.gumbel(F.np.zeros_like(sample_probs))
# Following the instruction of official repo to avoid deduplicate postions
Expand Down