示例#1
0
 def __init__(self, vocab_size, d_model, N, heads, dropout):
     super().__init__()
     self.N = N
     self.embed = Embedder(vocab_size, d_model)
     self.pe = PositionalEncoder(d_model, dropout=dropout)
     self.layers = get_clones(DecoderLayer(d_model, heads, dropout), N)
     self.norm = Norm(d_model)
示例#2
0
 def __init__(self, bert, hidden_size, num_hidden_layers, num_attention_heads, dropout):
     super().__init__()
     self.N = num_hidden_layers
     self.bert = bert
     self.pe = PositionalEncoder(hidden_size, dropout=dropout)
     self.layers = get_clones(DecoderLayer(hidden_size, num_attention_heads, dropout), num_hidden_layers)
     self.norm = Norm(hidden_size)
示例#3
0
 def __init__(self, vocab_size, d_model, N, heads, dropout, c, n_layers):
     super().__init__()
     self.N = N
     self.embed = Embedder(vocab_size, d_model)
     self.pe = PositionalEncoder(d_model, dropout=dropout)
     self.dynam = Ucb_bandit(n_layers, c)
     self.layer = EncoderLayer(d_model, heads, dropout)
     self.layers = get_clones(EncoderLayer(d_model, heads, dropout), N)
     self.norm = Norm(d_model)
示例#4
0
 def __init__(self, vocab_size, d_model, N, heads, dropout, field, word_emb,
              opt):
     super().__init__()
     self.N = N
     self.word_emb = word_emb
     self.opt = opt  # unused, just for querying
     self.embed = Embedder(vocab_size, d_model, word_emb, field)
     self.pe = PositionalEncoder(d_model, dropout=dropout)
     self.layers = get_clones(EncoderLayer(d_model, heads, dropout),
                              N)  # attention
     self.norm = Norm(d_model)
示例#5
0
    def __init__(self, vocab_size, d_model, N, heads, dropout, device):
        super().__init__()
        self.N = N

        # We need to use the embedder
        # self.embed = Embedder(vocab_size, d_model)
        # self.embed = nn.Linear(vocab_size, d_model)

        self.pe = PositionalEncoder(d_model, dropout=dropout, device=device)
        self.layers = get_clones(EncoderLayer(d_model, heads, dropout), N)
        self.norm = Norm(d_model)