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
fe2756ff
Commit
fe2756ff
authored
Apr 15, 2019
by
thomwolf
Browse files
update double head model
parent
b509bf76
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
1 deletion
+1
-1
pytorch_pretrained_bert/modeling_openai.py
pytorch_pretrained_bert/modeling_openai.py
+1
-1
No files found.
pytorch_pretrained_bert/modeling_openai.py
View file @
fe2756ff
...
@@ -371,7 +371,7 @@ class OpenAIGPTMultipleChoiceHead(nn.Module):
...
@@ -371,7 +371,7 @@ class OpenAIGPTMultipleChoiceHead(nn.Module):
def
forward
(
self
,
hidden_states
,
mc_token_ids
):
def
forward
(
self
,
hidden_states
,
mc_token_ids
):
# Classification logits
# Classification logits
# hidden_state (bsz, num_choices, seq_length, hidden_size)
# hidden_state (bsz, num_choices, seq_length, hidden_size)
# mc_token_ids (bsz, num_choices
, 1
)
# mc_token_ids (bsz, num_choices)
mc_token_ids
=
mc_token_ids
.
unsqueeze
(
-
1
).
unsqueeze
(
-
1
).
expand
(
-
1
,
-
1
,
-
1
,
hidden_states
.
size
(
-
1
))
mc_token_ids
=
mc_token_ids
.
unsqueeze
(
-
1
).
unsqueeze
(
-
1
).
expand
(
-
1
,
-
1
,
-
1
,
hidden_states
.
size
(
-
1
))
# (bsz, num_choices, 1, hidden_size)
# (bsz, num_choices, 1, hidden_size)
multiple_choice_h
=
hidden_states
.
gather
(
2
,
mc_token_ids
).
squeeze
(
2
)
multiple_choice_h
=
hidden_states
.
gather
(
2
,
mc_token_ids
).
squeeze
(
2
)
...
...
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