def apply_embeddings(self, inputs):
    'GPT2的embedding是token、position两者embedding之和\n        '
    x = inputs
    x = self.apply(inputs=x, layer=Embedding, input_dim=self.vocab_size, output_dim=self.embedding_size, embeddings_initializer=self.initializer, mask_zero=True, name='Embedding-Token')
    x = self.apply(inputs=x, layer=PositionEmbedding, input_dim=self.max_position, output_dim=self.embedding_size, merge_mode='add', hierarchical=self.hierarchical_position, embeddings_initializer=self.initializer, name='Embedding-Position')
    if (self.embedding_size != self.hidden_size):
        x = self.apply(inputs=x, layer=Dense, units=self.hidden_size, kernel_initializer=self.initializer, name='Embedding-Mapping')
    return x
GPT2的embedding是token、position两者embedding之和
def apply_embeddings(self, inputs):
    '\n        '
    x = inputs
    x = self.apply(inputs=x, layer=Embedding, input_dim=self.vocab_size, output_dim=self.embedding_size, embeddings_initializer=self.initializer, mask_zero=True, name='Embedding-Token')
    x = self.apply(inputs=x, layer=PositionEmbedding, input_dim=self.max_position, output_dim=self.embedding_size, merge_mode='add', hierarchical=self.hierarchical_position, embeddings_initializer=self.initializer, name='Embedding-Position')
    if (self.embedding_size != self.hidden_size):
        x = self.apply(inputs=x, layer=Dense, units=self.hidden_size, kernel_initializer=self.initializer, name='Embedding-Mapping')
    return x