Download annotations/annotation_12/TTM/models/classifier.py from mcy98/RECODE-H: direct link, hf CLI and curl.
- Browser
- Download file 819 Bytes
-
https://huggingface.co/datasets/mcy98/RECODE-H/resolve/main/annotations/annotation_12/TTM/models/classifier.py
- Command line
-
hf download hf://datasets/mcy98/RECODE-H/annotations/annotation_12/TTM/models/classifier.py
-
curl -L -o classifier.py https://huggingface.co/datasets/mcy98/RECODE-H/resolve/main/annotations/annotation_12/TTM/models/classifier.py
819 Bytes
| from __future__ import print_function | |
| import torch.nn as nn | |
| ######################################### | |
| # ===== Classifiers ===== # | |
| ######################################### | |
| class LinearClassifier(nn.Module): | |
| def __init__(self, dim_in, n_label=10): | |
| super(LinearClassifier, self).__init__() | |
| self.net = nn.Linear(dim_in, n_label) | |
| def forward(self, x): | |
| return self.net(x) | |
| class NonLinearClassifier(nn.Module): | |
| def __init__(self, dim_in, n_label=10, p=0.1): | |
| super(NonLinearClassifier, self).__init__() | |
| self.net = nn.Sequential( | |
| nn.Linear(dim_in, 200), | |
| nn.Dropout(p=p), | |
| nn.BatchNorm1d(200), | |
| nn.ReLU(inplace=True), | |
| nn.Linear(200, n_label), | |
| ) | |
| def forward(self, x): | |
| return self.net(x) | |