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
OpenDAS
FastMoE
Commits
56dd6dd4
Unverified
Commit
56dd6dd4
authored
Nov 10, 2021
by
Zilin Zhu
Committed by
GitHub
Nov 10, 2021
Browse files
Update proj_adaptive_softmax.py
parent
b294221d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
examples/transformer-xl/utils/proj_adaptive_softmax.py
examples/transformer-xl/utils/proj_adaptive_softmax.py
+2
-2
No files found.
examples/transformer-xl/utils/proj_adaptive_softmax.py
View file @
56dd6dd4
...
@@ -110,7 +110,7 @@ class ProjectedAdaptiveLogSoftmax(nn.Module):
...
@@ -110,7 +110,7 @@ class ProjectedAdaptiveLogSoftmax(nn.Module):
weights
.
append
(
weight_i
)
weights
.
append
(
weight_i
)
biases
.
append
(
bias_i
)
biases
.
append
(
bias_i
)
head_weight
,
head_bias
,
head_proj
=
weights
[
0
],
biases
[
0
],
self
.
out_projs
[
0
].
weight
head_weight
,
head_bias
,
head_proj
=
weights
[
0
],
biases
[
0
],
self
.
out_projs
[
0
].
weight
if
self
.
out_projs
[
0
]
is
not
None
else
None
head_logit
=
self
.
_compute_logit
(
hidden
,
head_weight
,
head_bias
,
head_proj
)
head_logit
=
self
.
_compute_logit
(
hidden
,
head_weight
,
head_bias
,
head_proj
)
head_logprob
=
F
.
log_softmax
(
head_logit
,
dim
=
1
)
head_logprob
=
F
.
log_softmax
(
head_logit
,
dim
=
1
)
...
@@ -135,7 +135,7 @@ class ProjectedAdaptiveLogSoftmax(nn.Module):
...
@@ -135,7 +135,7 @@ class ProjectedAdaptiveLogSoftmax(nn.Module):
if
i
==
0
:
if
i
==
0
:
logprob_i
=
head_logprob_i
.
gather
(
1
,
target_i
[:,
None
]).
squeeze
(
1
)
logprob_i
=
head_logprob_i
.
gather
(
1
,
target_i
[:,
None
]).
squeeze
(
1
)
else
:
else
:
weight_i
,
bias_i
,
proj_i
=
weights
[
i
],
biases
[
i
],
self
.
out_projs
[
i
].
weight
weight_i
,
bias_i
,
proj_i
=
weights
[
i
],
biases
[
i
],
self
.
out_projs
[
i
].
weight
if
self
.
out_projs
[
i
]
is
not
None
else
None
hidden_i
=
hidden
.
index_select
(
0
,
indices_i
)
hidden_i
=
hidden
.
index_select
(
0
,
indices_i
)
...
...
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