Download src/normalization.py from Snapkitty/nano-gemini: direct link, hf CLI and curl.
- Browser
- Download file 552 Bytes
-
https://huggingface.co/Snapkitty/nano-gemini/resolve/main/src/normalization.py
- Command line
-
hf download hf://Snapkitty/nano-gemini/src/normalization.py
-
curl -L -o normalization.py https://huggingface.co/Snapkitty/nano-gemini/resolve/main/src/normalization.py
552 Bytes
| from __future__ import annotations | |
| import numpy as np | |
| from .config import SIGMA_EPS | |
| def linear_interpolate(row: np.ndarray) -> np.ndarray: | |
| row = np.asarray(row, dtype=np.float64).copy() | |
| nan = ~np.isfinite(row) | |
| if not nan.any(): return row | |
| if nan.all(): return np.zeros_like(row) | |
| idx = np.arange(row.shape[0]) | |
| row[nan] = np.interp(idx[nan], idx[~nan], row[~nan]) | |
| return row | |
| def revin(x, mu, sigma, reverse=False): | |
| s = np.where(sigma < SIGMA_EPS, 1.0, sigma) | |
| return x*s+mu if reverse else (x-mu)/s | |