Unverified Commit 56dd6dd4 authored by Zilin Zhu's avatar Zilin Zhu Committed by GitHub
Browse files

Update proj_adaptive_softmax.py

parent b294221d
...@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment