Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
b9bb4173
Unverified
Commit
b9bb4173
authored
May 20, 2022
by
Daniel Stancl
Committed by
GitHub
May 20, 2022
Browse files
Fix a typo relative_postion_if_large -> relative_position_if_large (#17366)
parent
3fd7de49
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
8 deletions
+8
-8
src/transformers/models/t5/modeling_t5.py
src/transformers/models/t5/modeling_t5.py
+4
-4
src/transformers/models/wavlm/modeling_wavlm.py
src/transformers/models/wavlm/modeling_wavlm.py
+4
-4
No files found.
src/transformers/models/t5/modeling_t5.py
View file @
b9bb4173
...
...
@@ -408,16 +408,16 @@ class T5Attention(nn.Module):
is_small
=
relative_position
<
max_exact
# The other half of the buckets are for logarithmically bigger bins in positions up to max_distance
relative_postion_if_large
=
max_exact
+
(
relative_pos
i
tion_if_large
=
max_exact
+
(
torch
.
log
(
relative_position
.
float
()
/
max_exact
)
/
math
.
log
(
max_distance
/
max_exact
)
*
(
num_buckets
-
max_exact
)
).
to
(
torch
.
long
)
relative_postion_if_large
=
torch
.
min
(
relative_postion_if_large
,
torch
.
full_like
(
relative_postion_if_large
,
num_buckets
-
1
)
relative_pos
i
tion_if_large
=
torch
.
min
(
relative_pos
i
tion_if_large
,
torch
.
full_like
(
relative_pos
i
tion_if_large
,
num_buckets
-
1
)
)
relative_buckets
+=
torch
.
where
(
is_small
,
relative_position
,
relative_postion_if_large
)
relative_buckets
+=
torch
.
where
(
is_small
,
relative_position
,
relative_pos
i
tion_if_large
)
return
relative_buckets
def
compute_bias
(
self
,
query_length
,
key_length
):
...
...
src/transformers/models/wavlm/modeling_wavlm.py
View file @
b9bb4173
...
...
@@ -559,12 +559,12 @@ class WavLMAttention(nn.Module):
relative_positions_if_large
=
torch
.
log
(
relative_positions
.
float
()
/
max_exact
)
relative_positions_if_large
=
relative_positions_if_large
/
math
.
log
(
self
.
max_distance
/
max_exact
)
relative_positions_if_large
=
relative_positions_if_large
*
(
num_buckets
-
max_exact
)
relative_postion_if_large
=
(
max_exact
+
relative_positions_if_large
).
to
(
torch
.
long
)
relative_postion_if_large
=
torch
.
min
(
relative_postion_if_large
,
torch
.
full_like
(
relative_postion_if_large
,
num_buckets
-
1
)
relative_pos
i
tion_if_large
=
(
max_exact
+
relative_positions_if_large
).
to
(
torch
.
long
)
relative_pos
i
tion_if_large
=
torch
.
min
(
relative_pos
i
tion_if_large
,
torch
.
full_like
(
relative_pos
i
tion_if_large
,
num_buckets
-
1
)
)
relative_buckets
+=
torch
.
where
(
is_small
,
relative_positions
,
relative_postion_if_large
)
relative_buckets
+=
torch
.
where
(
is_small
,
relative_positions
,
relative_pos
i
tion_if_large
)
return
relative_buckets
...
...
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