Download source/model.py from ARotting/uncertainty-lens: direct link, hf CLI and curl.
- Browser
- Download file 894 Bytes
-
https://huggingface.co/ARotting/uncertainty-lens/resolve/main/source/model.py
- Command line
-
hf download hf://ARotting/uncertainty-lens/source/model.py
-
curl -L -o model.py https://huggingface.co/ARotting/uncertainty-lens/resolve/main/source/model.py
894 Bytes
| from __future__ import annotations | |
| import torch | |
| from torch import nn | |
| class ProbabilisticTinyCNN(nn.Module): | |
| def __init__(self) -> None: | |
| super().__init__() | |
| self.features = nn.Sequential( | |
| nn.Conv2d(1, 8, kernel_size=3, padding=1), | |
| nn.GELU(), | |
| nn.Conv2d(8, 8, kernel_size=3, padding=1, groups=8), | |
| nn.GELU(), | |
| nn.Conv2d(8, 12, kernel_size=1), | |
| nn.GELU(), | |
| nn.Dropout2d(0.08), | |
| nn.MaxPool2d(2), | |
| ) | |
| self.classifier = nn.Sequential( | |
| nn.Flatten(), | |
| nn.Dropout(0.12), | |
| nn.Linear(12 * 4 * 4, 10), | |
| ) | |
| def forward(self, pixels: torch.Tensor) -> torch.Tensor: | |
| return self.classifier(self.features(pixels)) | |
| def parameter_count(model: nn.Module) -> int: | |
| return sum(parameter.numel() for parameter in model.parameters()) | |