Download tests/test_v4_selective.py from kiruluta/Spectral-World-Models-Reproducibility: direct link, hf CLI and curl.
- Browser
- Download file 577 Bytes
-
https://huggingface.co/kiruluta/Spectral-World-Models-Reproducibility/resolve/main/tests/test_v4_selective.py
- Command line
-
hf download hf://kiruluta/Spectral-World-Models-Reproducibility/tests/test_v4_selective.py
-
curl -L -o test_v4_selective.py https://huggingface.co/kiruluta/Spectral-World-Models-Reproducibility/resolve/main/tests/test_v4_selective.py
577 Bytes
| import torch | |
| from spectral_world_models.models import SelectiveSpectralTransition | |
| def test_selective_caps_only_expansive_modes(): | |
| m=SelectiveSpectralTransition(16,5,n_ops=2,rank=4,max_gain=1.05) | |
| ids=torch.arange(5) | |
| _, raw, clipped=m.selective_matrix(ids) | |
| assert float(clipped.max()) <= 1.05001 | |
| mask=raw <= 1.05 | |
| assert torch.allclose(clipped[mask], raw[mask], atol=1e-6) | |
| def test_selective_forward_shape(): | |
| m=SelectiveSpectralTransition(16,5,n_ops=2,rank=4,max_gain=1.05) | |
| y=m(torch.randn(3,16),torch.tensor([0,1,4])) | |
| assert y.shape==(3,16) | |