Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. class GPT2Model(nn.Module):
  2.  
  3. def __init__(self, config):
  4. super(GPT2Model, self).__init__(config)
  5.  
  6. self.wte = nn.Embedding(config.vocab_size, config.n_embd)
  7. self.wpe = nn.Embedding(config.n_positions, config.n_embd)
  8.  
  9. self.drop = nn.Dropout(config.embd_pdrop)
  10. self.h = nn.ModuleList([Block(config.n_ctx, config, scale=True) for _ in range(config.n_layer)])
  11. self.ln_f = LayerNorm(config.n_embd, eps=config.layer_norm_epsilon)
  12.  
  13. self.apply(self.init_weights)
  14.  
  15. def init_weights(self):
  16. raise NotImplementedError
  17.  
  18. def forward(self, input_ids, past=None):
  19. raise NotImplementedError
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement