示例#1
0
 def __init__(self, vocab_size, d_model, N, heads, dropout, 最大长度=1024):
     super().__init__()
     self.N = N
     self.embed = Embedder(vocab_size, d_model)
     self.embedP = Embedder(最大长度, 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, vocab_size, d_model, N, heads, dropout):
     super().__init__()
     self.N = N
     self.embed = Embedder(vocab_size, d_model)
     #self.pe = PositionalEncoder(d_model=47, max_seq_len=13,dropout=dropout)
     self.layers = get_clones(EncoderLayer(d_model, heads, dropout), N)
     self.norm = Norm(d_model)
示例#3
0
 def __init__(self, vocab_size, d_model, N_layers, heads, dropout):
     super().__init__()
     self.N_layers = N_layers
     self.embed = Embedder(vocab_size, d_model)
     self.pe = PositionalEncoder(d_model, dropout=dropout)
     self.layers = get_clones(DecoderLayer(d_model, heads, dropout),
                              N_layers)
     self.norm = Norm(d_model)
示例#4
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)
示例#5
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)