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
9ef9c397
Unverified
Commit
9ef9c397
authored
Sep 07, 2020
by
Lysandre Debut
Committed by
GitHub
Sep 07, 2020
Browse files
Cannot index `None` (#6984)
parent
08de989a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
src/transformers/modeling_bert.py
src/transformers/modeling_bert.py
+4
-2
No files found.
src/transformers/modeling_bert.py
View file @
9ef9c397
...
@@ -464,6 +464,8 @@ class BertEncoder(nn.Module):
...
@@ -464,6 +464,8 @@ class BertEncoder(nn.Module):
if
output_hidden_states
:
if
output_hidden_states
:
all_hidden_states
=
all_hidden_states
+
(
hidden_states
,)
all_hidden_states
=
all_hidden_states
+
(
hidden_states
,)
layer_head_mask
=
head_mask
[
i
]
if
head_mask
is
not
None
else
None
if
getattr
(
self
.
config
,
"gradient_checkpointing"
,
False
):
if
getattr
(
self
.
config
,
"gradient_checkpointing"
,
False
):
def
create_custom_forward
(
module
):
def
create_custom_forward
(
module
):
...
@@ -476,7 +478,7 @@ class BertEncoder(nn.Module):
...
@@ -476,7 +478,7 @@ class BertEncoder(nn.Module):
create_custom_forward
(
layer_module
),
create_custom_forward
(
layer_module
),
hidden_states
,
hidden_states
,
attention_mask
,
attention_mask
,
head_mask
[
i
]
,
layer_
head_mask
,
encoder_hidden_states
,
encoder_hidden_states
,
encoder_attention_mask
,
encoder_attention_mask
,
)
)
...
@@ -484,7 +486,7 @@ class BertEncoder(nn.Module):
...
@@ -484,7 +486,7 @@ class BertEncoder(nn.Module):
layer_outputs
=
layer_module
(
layer_outputs
=
layer_module
(
hidden_states
,
hidden_states
,
attention_mask
,
attention_mask
,
head_mask
[
i
]
,
layer_
head_mask
,
encoder_hidden_states
,
encoder_hidden_states
,
encoder_attention_mask
,
encoder_attention_mask
,
output_attentions
,
output_attentions
,
...
...
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