Differentiable Persistence Landscape Layer / persistence_track.py
Failed on benchmark
1import numpy as np
2
3META = {
4 "name": "persistence_diagrams",
5 "domain": "topological_representation",
6 "description": "Classification of noisy variable-cardinality persistence diagrams; class is encoded by interval location and persistence."
7}
8
9
10def _make(seed, n):
11 rng = np.random.default_rng(seed)
12 ys = rng.integers(0, 2, size=n, dtype=np.int64)
13 out = np.zeros((n, 8, 2), dtype=np.float32)
14 for i, y in enumerate(ys):
15 m = int(rng.integers(2, 9))
16 center = 0.29 if y == 0 else 0.69
17 births = np.clip(rng.normal(center, 0.105, m), 0.03, 0.86)
18 persistence = np.clip(rng.normal(0.20, 0.065, m), 0.035, 0.38)
19 deaths = np.minimum(births + persistence, 0.97)
20 deaths = np.maximum(deaths, births + 0.015)
21 out[i, :m, 0] = births
22 out[i, :m, 1] = deaths
23 return out, ys
24
25
26def get_dataset(seed, n_train, n_test):
27 xtr, ytr = _make(int(seed) * 2 + 11, n_train)
28 xte, yte = _make(int(seed) * 2 + 10011, n_test)
29 return {
30 "xtr": xtr, "ytr": ytr, "xte": xte, "yte": yte,
31 "task": "classification", "metric": "err",
32 "input_shape": xtr.shape[1:], "out_dim": 2
33 }