Spaces:
Runtime error
Runtime error
Download src/pathoverse/classification/classifier.py from KondetiAravind/PathoVerse-AI: direct link, hf CLI and curl.
- Browser
- Download file 616 Bytes
-
https://huggingface.co/spaces/KondetiAravind/PathoVerse-AI/resolve/main/src/pathoverse/classification/classifier.py
- Command line
-
hf download hf://spaces/KondetiAravind/PathoVerse-AI/src/pathoverse/classification/classifier.py
-
curl -L -o classifier.py https://huggingface.co/spaces/KondetiAravind/PathoVerse-AI/resolve/main/src/pathoverse/classification/classifier.py
616 Bytes
| 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) |