为什么pooler在bert中使用tanh作为激活函数,而不是gelu



类BERTPooler(nn.Module(:definit(self,config(:super(BERTPooler,self(init((self-dense=nn。线性(config.hidden_size、config.hidden _size(self.activation=nn。Tanh((

def forward(self, hidden_states):
# We "pool" the model by simply taking the hidden state corresponding
# to the first token.
first_token_tensor = hidden_states[:, 0]
pooled_output = self.dense(first_token_tensor)
pooled_output = self.activation(pooled_output)
return pooled_output

BERT原始论文的作者在GitHub上的一条评论中回答了这个问题。

tanh((的事情很早就做了,试图让它更具可解释性,但这可能都无关紧要。

我同意它没有完全回答";是否";tanh更可取,但从外观上看,它可能适用于任何激活。

最新更新