Spaces:
Running on T4
Running on T4
Download src/interfaces/i_model.py from tisaconundrum/grassmann-ablation: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/spaces/tisaconundrum/grassmann-ablation/resolve/main/src/interfaces/i_model.py
- Command line
-
hf download hf://spaces/tisaconundrum/grassmann-ablation/src/interfaces/i_model.py
-
curl -L -o i_model.py https://huggingface.co/spaces/tisaconundrum/grassmann-ablation/resolve/main/src/interfaces/i_model.py
1.04 kB
| from abc import ABC, abstractmethod | |
| from typing import Any, Self | |
| import torch | |
| class IModel(ABC): | |
| """Interface for the trainable model.""" | |
| def build(self) -> Self: | |
| """Build / initialize the model architecture.""" | |
| ... | |
| def train(self, train_loader: Any, val_loader: Any, epochs: int) -> Self: | |
| """Train the model.""" | |
| ... | |
| def test(self, test_loader: Any) -> dict: | |
| """Evaluate on test set. Returns metrics dict.""" | |
| ... | |
| def fit(self, dataset: Any) -> Self: | |
| """Convenience: preprocess + train + validate in one call.""" | |
| ... | |
| def predict(self, audio: torch.Tensor) -> str: | |
| """Transcribe audio tensor to text.""" | |
| ... | |
| def save(self, path: str) -> Self: | |
| """Save model checkpoint.""" | |
| ... | |
| def load(self, path: str) -> Self: | |
| """Load model checkpoint.""" | |
| ... | |