bert参数

15375357604 / 2023-08-23 / 原文

bert结构:BERT-Base, Uncased: 12-layer, 768-hidden, 12-heads, 110M parameters,词典大小:30522

embeding层:

token embeding:30522*768,获取每个token的初始编码

position embeding: 512*768

type embeding:2*768

layer norm:wight+bias 768*2

self_attention层:

query,key,value:(768*768+768)*3

dense:768*768+768

layer norm:wight+bias 768*2

feed_forward:

两层,先升后降

layer norm:wight+bias 768*2

 

bert.embeddings.word_embeddings.weight torch.Size([30522, 768]) 参数个数为: 23440896

bert.embeddings.position_embeddings.weight torch.Size([512, 768]) 参数个数为: 393216

bert.embeddings.token_type_embeddings.weight torch.Size([2, 768]) 参数个数为: 1536

bert.embeddings.LayerNorm.weight torch.Size([768]) 参数个数为: 768

bert.embeddings.LayerNorm.bias torch.Size([768]) 参数个数为: 768

bert.encoder.layer.0.attention.self.query.weight torch.Size([768, 768]) 参数个数为: 589824

bert.encoder.layer.0.attention.self.query.bias torch.Size([768]) 参数个数为: 768

bert.encoder.layer.0.attention.self.key.weight torch.Size([768, 768]) 参数个数为: 589824

bert.encoder.layer.0.attention.self.key.bias torch.Size([768]) 参数个数为: 768

bert.encoder.layer.0.attention.self.value.weight torch.Size([768, 768]) 参数个数为: 589824

bert.encoder.layer.0.attention.self.value.bias torch.Size([768]) 参数个数为: 768

bert.encoder.layer.0.attention.output.dense.weight torch.Size([768, 768]) 参数个数为: 589824

bert.encoder.layer.0.attention.output.dense.bias torch.Size([768]) 参数个数为: 768

bert.encoder.layer.0.attention.output.LayerNorm.weight torch.Size([768]) 参数个数为: 768

bert.encoder.layer.0.attention.output.LayerNorm.bias torch.Size([768]) 参数个数为: 768

bert.encoder.layer.0.intermediate.dense.weight torch.Size([3072, 768]) 参数个数为: 2359296

bert.encoder.layer.0.intermediate.dense.bias torch.Size([3072]) 参数个数为: 3072

bert.encoder.layer.0.output.dense.weight torch.Size([768, 3072]) 参数个数为: 2359296

bert.encoder.layer.0.output.dense.bias torch.Size([768]) 参数个数为: 768

bert.encoder.layer.0.output.LayerNorm.weight torch.Size([768]) 参数个数为: 768

bert.encoder.layer.0.output.LayerNorm.bias torch.Size([768]) 参数个数为: 768