MCPcopy
hub / github.com/deepspeedai/DeepSpeedExamples / BertPooler

Class BertPooler

bing_bert/nvidia/modeling.py:523–533  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

521
522
523class BertPooler(nn.Module):
524 def __init__(self, config):
525 super(BertPooler, self).__init__()
526 self.dense_act = LinearActivation(config.hidden_size, config.hidden_size, act="tanh")
527
528 def forward(self, hidden_states):
529 # We "pool" the model by simply taking the hidden state corresponding
530 # to the first token.
531 first_token_tensor = hidden_states[:, 0]
532 pooled_output = self.dense_act(first_token_tensor)
533 return pooled_output
534
535
536class BertPredictionHeadTransform(nn.Module):

Callers 1

__init__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected