MCPcopy Index your code
hub / github.com/THUDM/GLM / BertPooler

Class BertPooler

model/modeling_bert.py:575–587  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

573
574
575class BertPooler(nn.Module):
576 def __init__(self, config):
577 super(BertPooler, self).__init__()
578 self.dense = nn.Linear(config.hidden_size, config.hidden_size)
579 self.activation = nn.Tanh()
580
581 def forward(self, hidden_states):
582 # We "pool" the model by simply taking the hidden state corresponding
583 # to the first token.
584 first_token_tensor = hidden_states[:, 0]
585 pooled_output = self.dense(first_token_tensor)
586 pooled_output = self.activation(pooled_output)
587 return pooled_output
588
589
590class BertPredictionHeadTransform(nn.Module):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected