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
472857c4
Commit
472857c4
authored
Mar 24, 2019
by
Catalin Voss
Browse files
Fix typo syntax err (sorry, c/p from my repo)
parent
2e6f5ffb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
2 deletions
+2
-2
pytorch_pretrained_bert/modeling_gpt2.py
pytorch_pretrained_bert/modeling_gpt2.py
+1
-1
pytorch_pretrained_bert/modeling_openai.py
pytorch_pretrained_bert/modeling_openai.py
+1
-1
No files found.
pytorch_pretrained_bert/modeling_gpt2.py
View file @
472857c4
...
@@ -625,7 +625,7 @@ class GPT2LMHeadModel(GPT2PreTrainedModel):
...
@@ -625,7 +625,7 @@ class GPT2LMHeadModel(GPT2PreTrainedModel):
# in pytorch, it's [batch, num_classes, d_0, d_1, ..., d_{r-1}]
# in pytorch, it's [batch, num_classes, d_0, d_1, ..., d_{r-1}]
# We just flatten the tokens out this way.
# We just flatten the tokens out this way.
loss_fct
=
CrossEntropyLoss
(
ignore_index
=-
1
)
loss_fct
=
CrossEntropyLoss
(
ignore_index
=-
1
)
loss
=
loss_fct
(
shift_logits
.
view
(
-
1
,
shift_logits
.
size
(
-
1
))
loss
=
loss_fct
(
shift_logits
.
view
(
-
1
,
shift_logits
.
size
(
-
1
))
,
shift_labels
.
view
(
-
1
))
shift_labels
.
view
(
-
1
))
return
loss
return
loss
return
lm_logits
,
presents
return
lm_logits
,
presents
...
...
pytorch_pretrained_bert/modeling_openai.py
View file @
472857c4
...
@@ -724,7 +724,7 @@ class OpenAIGPTLMHeadModel(OpenAIGPTPreTrainedModel):
...
@@ -724,7 +724,7 @@ class OpenAIGPTLMHeadModel(OpenAIGPTPreTrainedModel):
# in pytorch, it's [batch, num_classes, d_0, d_1, ..., d_{r-1}]
# in pytorch, it's [batch, num_classes, d_0, d_1, ..., d_{r-1}]
# We just flatten the tokens out this way.
# We just flatten the tokens out this way.
loss_fct
=
CrossEntropyLoss
(
ignore_index
=-
1
)
loss_fct
=
CrossEntropyLoss
(
ignore_index
=-
1
)
loss
=
loss_fct
(
shift_logits
.
view
(
-
1
,
shift_logits
.
size
(
-
1
))
loss
=
loss_fct
(
shift_logits
.
view
(
-
1
,
shift_logits
.
size
(
-
1
))
,
shift_labels
.
view
(
-
1
))
shift_labels
.
view
(
-
1
))
return
loss
return
loss
return
lm_logits
return
lm_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