본문 바로가기

BERT코드3

[Pytorch][BERT] 버트 소스코드 이해_⑩ BERT Layer [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 BertLayer 1. BertLayer의 init() ✔ transformers.apply_chunking_to_forward : 연산 효율화를 위해 chunk를 나누어서 계산한다. : This function chunks the input_tensors into smaller input tensor parts of size chunk_siz.. 2022. 10. 28.
[Pytorch][BERT] 버트 소스코드 이해_⑧ BERT model 입력값 [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 BertModel 입력값 - BERT 모델을 생성한 후, forward 함수에서 필요한 입력값 class BertModel(BertPreTrainedModel): def forward( self, input_ids, attention_mask, token_type_ids, position_ids, head_mask, inputs_embeds, .. 2022. 10. 28.
[Pytorch][BERT] 버트 소스코드 이해_⑦ Bert Pooler [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 BertPooler : 마지막 hidden_state의 첫번째 토큰인 [CLS] 토큰의 embedding을 반환 We "pool" the model by simply taking the hidden state corresponding to the first token. The pooling layer at the end of the BERT m.. 2022. 10. 28.