Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
805db1fe
Unverified
Commit
805db1fe
authored
May 02, 2023
by
Alex Punnen
Committed by
GitHub
May 02, 2023
Browse files
num_noise_spans should be <= num_items #22246 (#22938)
parent
9ade58f0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
examples/flax/language-modeling/run_t5_mlm_flax.py
examples/flax/language-modeling/run_t5_mlm_flax.py
+3
-2
No files found.
examples/flax/language-modeling/run_t5_mlm_flax.py
View file @
805db1fe
...
@@ -418,13 +418,14 @@ class FlaxDataCollatorForT5MLM:
...
@@ -418,13 +418,14 @@ class FlaxDataCollatorForT5MLM:
orig_length
=
length
orig_length
=
length
num_noise_tokens
=
int
(
np
.
round
(
length
*
self
.
noise_density
))
num_noise_tokens
=
int
(
np
.
round
(
length
*
self
.
noise_density
))
num_nonnoise_tokens
=
length
-
num_noise_tokens
# avoid degeneracy by ensuring positive numbers of noise and nonnoise tokens.
# avoid degeneracy by ensuring positive numbers of noise and nonnoise tokens.
num_noise_tokens
=
min
(
max
(
num_noise_tokens
,
1
),
length
-
1
)
num_noise_tokens
=
min
(
max
(
num_noise_tokens
,
1
),
length
-
1
)
num_noise_spans
=
int
(
np
.
round
(
num_noise_tokens
/
self
.
mean_noise_span_length
))
# num_noise_tokens should be less than num_noise_tokens and num_nonnoise_tokens
num_noise_spans
=
int
(
np
.
round
(
min
(
num_noise_tokens
,
num_nonnoise_tokens
)
/
self
.
mean_noise_span_length
))
# avoid degeneracy by ensuring positive number of noise spans
# avoid degeneracy by ensuring positive number of noise spans
num_noise_spans
=
max
(
num_noise_spans
,
1
)
num_noise_spans
=
max
(
num_noise_spans
,
1
)
num_nonnoise_tokens
=
length
-
num_noise_tokens
# pick the lengths of the noise spans and the non-noise spans
# pick the lengths of the noise spans and the non-noise spans
def
_random_segmentation
(
num_items
,
num_segments
):
def
_random_segmentation
(
num_items
,
num_segments
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment