본문 바로가기
AI/딥러닝 기초(Deep learning)

[Pytorch][BERT] 버트 소스코드 이해_⑪ BertSelfAttention

by Hyen4110 2022. 10. 28.
반응형

[Pytorch][BERT] 버트 소스코드 이해 목차

BERT 📑 BERT Config    
  📑 BERT Tokenizer      
  📑 BERT Model 📑 BERT Input    
    📑 BERT Output    
    📑 BERT Embedding    
    📑 BERT Pooler    
    📑 BERT Enocder 📑 BERT Layer 📑 BERT SelfAttention  👀
        📑 BERT SelfOtput

BertSelfAttention

 

1. Attetion Process

1) key, query, value 생성

: 전체 hiddens_size를 실제로 attention 연산을 적용할 크기로 축소한다

 

2) attention score 구한다

 

3) context vector 구한다 (=output)

 

<소스 코드 내>

✔ num_attention_heads

: (int, optional, defaults to 12)

: Number of attention heads for each attention layer in the Transformer encoder.

반응형

댓글