1.剔除中间并列的元素,只保留一个元素
2.从里层配对括号开始标记
3.标记层次 配对的括号 标上相同的符号
<bound method BertPreTrainedModel.init_bert_weights of BertForTokenClassification(
(bert): 第一层BertModel(
(embeddings):第二层 BertEmbeddings(
(word_embeddings):
)
(encoder):第二层 BertEncoder(
(layer): ModuleList(
(0): BertLayer(
(attention): BertAttention(
(self): BertSelfAttention(
(query):
)
(output): BertSelfOutput(
(dense):
)
)BertAttention
(intermediate): BertIntermediate(
(dense):
)BertIntermediate
(output): BertOutput(
(dense):
) BertOutput
)BertLayer
分离
)ModuleList
)BertEncoder
第二层(pooler): BertPooler(
(dense):
)BertPooler
)BertModel
第一层(dropout): Dropout(p=0.1)
第一层(classifier): Linear(in_features=768, out_features=39, bias=True)
)>
以上是bert 模型的结构
1.最外层 先经过bertmodel,然后是droput,最后是classifier 分类器
2.第二层 对于 bertmodel,组成部分是 BertEmbeddings,BertEncoder,BertPooler
3.第三层是对于上面三个组成部分的再深入比如 bertEncoder 里面组成部分是 BertLayer
4.第四层BertLayer 里面的组成成分BertAttention,BertIntermediate, BertOutput
5.所有的BertLayer 在list 相当于是串联的方式组成的