MCPcopy Create free account
hub / github.com/MiniMax-AI/VTP / LinearClassifier

Class LinearClassifier

tools/test_linear_probing_hf.py:155–170  ·  view source on GitHub ↗

Linear classifier on top of frozen features.

Source from the content-addressed store, hash-verified

153
154
155class LinearClassifier(nn.Module):
156 """Linear classifier on top of frozen features."""
157
158 def __init__(self, out_dim: int, use_n_blocks: int, use_avgpool: bool, num_classes: int = 1000):
159 super().__init__()
160 self.out_dim = out_dim
161 self.use_n_blocks = use_n_blocks
162 self.use_avgpool = use_avgpool
163 self.num_classes = num_classes
164 self.linear = nn.Linear(out_dim, num_classes)
165 self.linear.weight.data.normal_(mean=0.0, std=0.01)
166 self.linear.bias.data.zero_()
167
168 def forward(self, x_tokens_list):
169 output = create_linear_input(x_tokens_list, self.use_n_blocks, self.use_avgpool)
170 return self.linear(output)
171
172
173class AllClassifiers(nn.Module):

Callers 1

setup_linear_classifiersFunction · 0.85

Calls

no outgoing calls

Tested by 1

setup_linear_classifiersFunction · 0.68