Download model/dataset.py from OneScience-Group/Spherical-Fourier-Neural-Operators: direct link, hf CLI and curl.
- Browser
- Download file 623 Bytes
-
https://huggingface.co/OneScience-Group/Spherical-Fourier-Neural-Operators/resolve/main/model/dataset.py
- Command line
-
hf download hf://OneScience-Group/Spherical-Fourier-Neural-Operators/model/dataset.py
-
curl -L -o dataset.py https://huggingface.co/OneScience-Group/Spherical-Fourier-Neural-Operators/resolve/main/model/dataset.py
623 Bytes
| """Pair and split the deterministic spherical sequence for SFNO training.""" | |
| from torch.utils.data import Dataset | |
| class SphericalPairDataset(Dataset): | |
| def __init__(self, fields, start, stop): | |
| self.fields = fields | |
| self.start = start | |
| self.stop = min(stop, fields.shape[0] - 1) | |
| if self.stop <= self.start: | |
| raise ValueError("A spherical split must contain at least one input/target pair") | |
| def __len__(self): | |
| return self.stop - self.start | |
| def __getitem__(self, index): | |
| step = self.start + index | |
| return self.fields[step], self.fields[step + 1] | |