Spaces:
Runtime error
Runtime error
File size: 616 Bytes
2a146da | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | from __future__ import annotations
import torch
from torch import nn
class LinearClassifier(nn.Module):
"""
Lightweight linear classifier operating on frozen
foundation-model embeddings.
"""
def __init__(
self,
input_dim: int,
num_classes: int = 2,
):
super().__init__()
self.input_dim = input_dim
self.num_classes = num_classes
self.classifier = nn.Linear(
input_dim,
num_classes,
)
def forward(
self,
x: torch.Tensor,
) -> torch.Tensor:
return self.classifier(x) |