def variable_mapping(self):
    '映射到官方BERT权重格式\n        '
    mapping = {'Embedding-Token': ['bert/embeddings/word_embeddings'], 'Embedding-Segment': ['bert/embeddings/token_type_embeddings'], 'Embedding-Position': ['bert/embeddings/position_embeddings'], 'Embedding-Norm': ['bert/embeddings/LayerNorm/beta', 'bert/embeddings/LayerNorm/gamma'], 'Embedding-Mapping': ['bert/encoder/embedding_hidden_mapping_in/kernel', 'bert/encoder/embedding_hidden_mapping_in/bias'], 'Pooler-Dense': ['bert/pooler/dense/kernel', 'bert/pooler/dense/bias'], 'NSP-Proba': ['cls/seq_relationship/output_weights', 'cls/seq_relationship/output_bias'], 'MLM-Dense': ['cls/predictions/transform/dense/kernel', 'cls/predictions/transform/dense/bias'], 'MLM-Norm': ['cls/predictions/transform/LayerNorm/beta', 'cls/predictions/transform/LayerNorm/gamma'], 'MLM-Bias': ['cls/predictions/output_bias']}
    for i in range(self.num_hidden_layers):
        prefix = ('bert/encoder/layer_%d/' % i)
        mapping.update({('Transformer-%d-MultiHeadSelfAttention' % i): [(prefix + 'attention/self/query/kernel'), (prefix + 'attention/self/query/bias'), (prefix + 'attention/self/key/kernel'), (prefix + 'attention/self/key/bias'), (prefix + 'attention/self/value/kernel'), (prefix + 'attention/self/value/bias'), (prefix + 'attention/output/dense/kernel'), (prefix + 'attention/output/dense/bias')], ('Transformer-%d-MultiHeadSelfAttention-Norm' % i): [(prefix + 'attention/output/LayerNorm/beta'), (prefix + 'attention/output/LayerNorm/gamma')], ('Transformer-%d-FeedForward' % i): [(prefix + 'intermediate/dense/kernel'), (prefix + 'intermediate/dense/bias'), (prefix + 'output/dense/kernel'), (prefix + 'output/dense/bias')], ('Transformer-%d-FeedForward-Norm' % i): [(prefix + 'output/LayerNorm/beta'), (prefix + 'output/LayerNorm/gamma')]})
    return mapping
映射到官方BERT权重格式
def variable_mapping(self):
    '\n        '
    mapping = {'Embedding-Token': ['bert/embeddings/word_embeddings'], 'Embedding-Segment': ['bert/embeddings/token_type_embeddings'], 'Embedding-Position': ['bert/embeddings/position_embeddings'], 'Embedding-Norm': ['bert/embeddings/LayerNorm/beta', 'bert/embeddings/LayerNorm/gamma'], 'Embedding-Mapping': ['bert/encoder/embedding_hidden_mapping_in/kernel', 'bert/encoder/embedding_hidden_mapping_in/bias'], 'Pooler-Dense': ['bert/pooler/dense/kernel', 'bert/pooler/dense/bias'], 'NSP-Proba': ['cls/seq_relationship/output_weights', 'cls/seq_relationship/output_bias'], 'MLM-Dense': ['cls/predictions/transform/dense/kernel', 'cls/predictions/transform/dense/bias'], 'MLM-Norm': ['cls/predictions/transform/LayerNorm/beta', 'cls/predictions/transform/LayerNorm/gamma'], 'MLM-Bias': ['cls/predictions/output_bias']}
    for i in range(self.num_hidden_layers):
        prefix = ('bert/encoder/layer_%d/' % i)
        mapping.update({('Transformer-%d-MultiHeadSelfAttention' % i): [(prefix + 'attention/self/query/kernel'), (prefix + 'attention/self/query/bias'), (prefix + 'attention/self/key/kernel'), (prefix + 'attention/self/key/bias'), (prefix + 'attention/self/value/kernel'), (prefix + 'attention/self/value/bias'), (prefix + 'attention/output/dense/kernel'), (prefix + 'attention/output/dense/bias')], ('Transformer-%d-MultiHeadSelfAttention-Norm' % i): [(prefix + 'attention/output/LayerNorm/beta'), (prefix + 'attention/output/LayerNorm/gamma')], ('Transformer-%d-FeedForward' % i): [(prefix + 'intermediate/dense/kernel'), (prefix + 'intermediate/dense/bias'), (prefix + 'output/dense/kernel'), (prefix + 'output/dense/bias')], ('Transformer-%d-FeedForward-Norm' % i): [(prefix + 'output/LayerNorm/beta'), (prefix + 'output/LayerNorm/gamma')]})
    return mapping