コード例 #1
0
    def __init__(self,
                 embedding_layer, n_layers, n_heads, d_model, d_filter, dropout = None) -> None:
        super(TransformerEncoder, self).__init__()

        self.embedding_layer = embedding_layer
        # The encoding stack is a stack of transformer encoder blocks
        self.encoding_stack = Stack([TransformerEncoderBlock(n_heads, d_filter, d_model, dropout)
                                     for _ in range(n_layers)],
                                    name='encoder_stack')
コード例 #2
0
 def __init__(self,
              embedding_layer,
              output_layer,
              n_layers,
              n_heads,
              d_model,
              d_filter,
              dropout = None) -> None:
     super().__init__()
     self.embedding_layer = embedding_layer
     self.decoding_stack = Stack([TransformerDecoderBlock(n_heads, d_filter, d_model, dropout)
                                  for _ in range(n_layers)],
                                 name='decoder_blocks')
     self.output_layer = output_layer