Semantic Pushforward Uncertainty Head / semantic_track.py
Mechanism confirmed, baseline not beaten
1import numpy as np
2
3META = {
4 "name": "semantic_pushforward_classification",
5 "domain": "uncertainty_calibration",
6 "description": "Synthetic finite-state classification with multiple verbal continuations per state and controlled response-logit distortion; evaluates calibrated semantic pushforward."
7}
8
9
10def get_dataset(seed, n_train, n_test):
11 rng = np.random.default_rng(int(seed))
12 k, d = 3, 8
13 W = rng.normal(0, 0.8, (k, d))
14
15 def sample(n):
16 x = rng.normal(size=(n, d)).astype(np.float32)
17 z = x @ W.T + 0.45 * np.sin(x[:, :3] @ W[:, :3].T)
18 q = np.exp(z - z.max(1, keepdims=True))
19 q /= q.sum(1, keepdims=True)
20 y = np.array([rng.choice(k, p=p) for p in q], dtype=np.int64)
21 return x, y
22
23 xtr, ytr = sample(int(n_train))
24 xte, yte = sample(int(n_test))
25 return {
26 "xtr": xtr, "ytr": ytr, "xte": xte, "yte": yte,
27 "task": "classification", "metric": "error",
28 "out_dim": k, "input_shape": (d,)
29 }