mirror of
https://github.com/wassname/openai-transformer-lm-gutenberg-erotic.git
synced 2026-06-27 16:10:19 +08:00
Adding commentaries and fixing a syntax mistake.
This commit is contained in:
+5
-1
@@ -206,8 +206,12 @@ class ClfHead(nn.Module):
|
||||
flat = x[:, :, :, 0].contiguous().view(-1)
|
||||
clf_h = clf_h[flat == self.clf_token, :]
|
||||
clf_h = clf_h.view(-1, x.size(1), self.n_embd, 1)
|
||||
# This double transposition is there to replicate the behavior
|
||||
# of the noise_shape argument in the tensorflow
|
||||
# implementation. For more details, see
|
||||
# https://github.com/huggingface/pytorch-openai-transformer-lm/issues/11
|
||||
clf_h = self.dropout(clf_h.transpose(1, 2)).transpose(1, 2)
|
||||
clf_h = clf_h.continuous.view(-1, self.n_embd)
|
||||
clf_h = clf_h.contiguous().view(-1, self.n_embd)
|
||||
clf_logits = self.linear(clf_h)
|
||||
return clf_logits.view(-1, x.size(1))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user