Download source/data.py from ARotting/factorial-code-forge: direct link, hf CLI and curl.
- Browser
- Download file 523 Bytes
-
https://huggingface.co/ARotting/factorial-code-forge/resolve/main/source/data.py
- Command line
-
hf download hf://ARotting/factorial-code-forge/source/data.py
-
curl -L -o data.py https://huggingface.co/ARotting/factorial-code-forge/resolve/main/source/data.py
523 Bytes
| from __future__ import annotations | |
| import numpy as np | |
| def generate_sources(samples: int, seed: int) -> tuple[np.ndarray, np.ndarray]: | |
| rng = np.random.default_rng(seed) | |
| source1 = rng.laplace(size=samples) / np.sqrt(2) | |
| source2 = rng.uniform(-np.sqrt(3), np.sqrt(3), size=samples) | |
| sources = np.column_stack([source1, source2]).astype(np.float32) | |
| mixing = np.asarray([[1.0, 0.85], [0.55, 1.25]], dtype=np.float32) | |
| observations = sources @ mixing.T | |
| return sources, observations.astype(np.float32) | |