Download src/sparsewake/models.py from SparseWake/sparsewake: direct link, hf CLI and curl.
- Browser
- Download file 655 Bytes
-
https://huggingface.co/datasets/SparseWake/sparsewake/resolve/4bf428f931dbe5364fd322d691d96d4fbeb3f6fb/src/sparsewake/models.py
- Command line
-
hf download hf://datasets/SparseWake/sparsewake@4bf428f931dbe5364fd322d691d96d4fbeb3f6fb/src/sparsewake/models.py
-
curl -L -o models.py https://huggingface.co/datasets/SparseWake/sparsewake/resolve/4bf428f931dbe5364fd322d691d96d4fbeb3f6fb/src/sparsewake/models.py
655 Bytes
| from __future__ import annotations | |
| import torch | |
| from torch import nn | |
| class TemporalMLP(nn.Module): | |
| def __init__(self, input_dim: int, output_dim: int = 2, hidden: tuple[int, ...] = (256, 256, 128), dropout: float = 0.05): | |
| super().__init__() | |
| layers: list[nn.Module] = [] | |
| last = input_dim | |
| for width in hidden: | |
| layers.extend([nn.Linear(last, width), nn.LayerNorm(width), nn.GELU(), nn.Dropout(dropout)]) | |
| last = width | |
| layers.append(nn.Linear(last, output_dim)) | |
| self.net = nn.Sequential(*layers) | |
| def forward(self, x: torch.Tensor) -> torch.Tensor: | |
| return self.net(x) | |