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
a4e1a1d0
Unverified
Commit
a4e1a1d0
authored
Jun 10, 2024
by
amyeroberts
Committed by
GitHub
Jun 10, 2024
Browse files
🚨
FLAVA: Remove double softmax (#31322)
Remove double softmax
parent
8fff07de
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
3 deletions
+1
-3
src/transformers/models/flava/modeling_flava.py
src/transformers/models/flava/modeling_flava.py
+0
-2
tests/models/flava/test_modeling_flava.py
tests/models/flava/test_modeling_flava.py
+1
-1
No files found.
src/transformers/models/flava/modeling_flava.py
View file @
a4e1a1d0
...
@@ -472,8 +472,6 @@ class FlavaSelfAttention(nn.Module):
...
@@ -472,8 +472,6 @@ class FlavaSelfAttention(nn.Module):
# Normalize the attention scores to probabilities.
# Normalize the attention scores to probabilities.
attention_probs
=
nn
.
functional
.
softmax
(
attention_scores
,
dim
=-
1
)
attention_probs
=
nn
.
functional
.
softmax
(
attention_scores
,
dim
=-
1
)
# Normalize the attention scores to probabilities.
attention_probs
=
nn
.
functional
.
softmax
(
attention_scores
,
dim
=-
1
)
# This is actually dropping out entire tokens to attend to, which might
# This is actually dropping out entire tokens to attend to, which might
# seem a bit unusual, but is taken from the original Transformer paper.
# seem a bit unusual, but is taken from the original Transformer paper.
...
...
tests/models/flava/test_modeling_flava.py
View file @
a4e1a1d0
...
@@ -1285,7 +1285,7 @@ class FlavaModelIntegrationTest(unittest.TestCase):
...
@@ -1285,7 +1285,7 @@ class FlavaModelIntegrationTest(unittest.TestCase):
# verify the embeddings
# verify the embeddings
self
.
assertAlmostEqual
(
outputs
.
image_embeddings
.
sum
().
item
(),
-
1352.53540
,
places
=
4
)
self
.
assertAlmostEqual
(
outputs
.
image_embeddings
.
sum
().
item
(),
-
1352.53540
,
places
=
4
)
self
.
assertAlmostEqual
(
outputs
.
text_embeddings
.
sum
().
item
(),
-
198.98225
,
places
=
4
)
self
.
assertAlmostEqual
(
outputs
.
text_embeddings
.
sum
().
item
(),
-
198.98225
,
places
=
4
)
self
.
assertAlmostEqual
(
outputs
.
multimodal_embeddings
.
sum
().
item
(),
-
4030.460
2050
,
places
=
4
)
self
.
assertAlmostEqual
(
outputs
.
multimodal_embeddings
.
sum
().
item
(),
-
4030.460
4492
,
places
=
4
)
@
require_vision
@
require_vision
...
...
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