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
461ae868
"...git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "2a4b9e09c02201ec5d45aa8cf49b667d04a5279e"
Unverified
Commit
461ae868
authored
Aug 26, 2020
by
Jay Yip
Committed by
GitHub
Aug 26, 2020
Browse files
Fix tf boolean mask in graph mode (#6741)
parent
925f34bb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
1 deletion
+1
-1
src/transformers/modeling_tf_utils.py
src/transformers/modeling_tf_utils.py
+1
-1
No files found.
src/transformers/modeling_tf_utils.py
View file @
461ae868
...
@@ -137,7 +137,7 @@ class TFCausalLanguageModelingLoss:
...
@@ -137,7 +137,7 @@ class TFCausalLanguageModelingLoss:
)
)
# make sure only labels that are not equal to -100
# make sure only labels that are not equal to -100
# are taken into account as loss
# are taken into account as loss
active_loss
=
tf
.
reshape
(
labels
,
(
-
1
,))
!=
-
100
active_loss
=
tf
.
not_equal
(
tf
.
reshape
(
labels
,
(
-
1
,))
,
-
100
)
reduced_logits
=
tf
.
boolean_mask
(
tf
.
reshape
(
logits
,
(
-
1
,
shape_list
(
logits
)[
2
])),
active_loss
)
reduced_logits
=
tf
.
boolean_mask
(
tf
.
reshape
(
logits
,
(
-
1
,
shape_list
(
logits
)[
2
])),
active_loss
)
labels
=
tf
.
boolean_mask
(
tf
.
reshape
(
labels
,
(
-
1
,)),
active_loss
)
labels
=
tf
.
boolean_mask
(
tf
.
reshape
(
labels
,
(
-
1
,)),
active_loss
)
return
loss_fn
(
labels
,
reduced_logits
)
return
loss_fn
(
labels
,
reduced_logits
)
...
...
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