Spaces:
Sleeping
Sleeping
Download src/classifier.py from ytkoa/TextClassifier: direct link, hf CLI and curl.
- Browser
- Download file 377 Bytes
-
https://huggingface.co/spaces/ytkoa/TextClassifier/resolve/main/src/classifier.py
- Command line
-
hf download hf://spaces/ytkoa/TextClassifier/src/classifier.py
-
curl -L -o classifier.py https://huggingface.co/spaces/ytkoa/TextClassifier/resolve/main/src/classifier.py
377 Bytes
| import torch | |
| import torch.nn as nn | |
| class Classifier(nn.Module): | |
| def __init__(self, bert_model): | |
| super().__init__() | |
| self.bert = bert_model | |
| self.head = nn.Linear(self.bert.model.config.hidden_size, 1) | |
| def forward(self, texts:list[str]): | |
| embeddings = self.bert(texts) | |
| return torch.sigmoid(self.head(embeddings)).squeeze(1) |