classification head for transformer encoders def initself classsize embedsize super init self classsize classsize self embedsize embedsize self mlp1 nn linearembedsize embedsize self mlp2 nn linearembedsize classsize self mlp nn linearembedsize classsize def forwardself hiddenstate hiddenstate nn functional reluself mlp1hiddenstate hiddenstate self mlp2hiddenstate logits self mlphiddenstate return logits classification head for transformer encoders self mlp1 nn linear embed_size embed_size self mlp2 nn linear embed_size class_size hidden_state nn functional relu self mlp1 hidden_state hidden_state self mlp2 hidden_state
from torch import nn


class ClassificationHead(nn.Module):
    

    def __init__(self, class_size, embed_size):
        super().__init__()
        self.class_size = class_size
        self.embed_size = embed_size
        
        
        self.mlp = nn.Linear(embed_size, class_size)

    def forward(self, hidden_state):
        
        
        logits = self.mlp(hidden_state)
        return logits