Skip to content

Commit 18b58c2

Browse files
committed
Remove data artifacts and obsolete doc; harden tensor ops
1 parent 2373f99 commit 18b58c2

15 files changed

+89
-1297
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ $$
2424
To work with these files on your own machine:
2525

2626
1. Clone or update the repository (`git clone` the first time, otherwise `git pull`).
27-
2. Change into the `Operations-Tensorielles-Simpliciales` directory.
27+
2. Change into the `SimplicialTensors` directory.
2828
3. Install the package in editable mode:
2929

3030
```bash
@@ -38,7 +38,7 @@ You can then import modules via `import simplicial_tensors.tensor_ops`.
3838
The interactive demonstrations that used to live inside the library modules now reside in the `examples/` folder. After installing the project in editable mode (`pip install -e .`), run any example like so:
3939

4040
```bash
41-
python examples/tensor_ops.py
41+
python examples/ab_mlp_demo.py
4242
```
4343

4444
Each script imports the corresponding module under `simplicial_tensors` and calls its `main()` entry point.
-9.77 KB
Binary file not shown.
-4.44 KB
Binary file not shown.
-58.6 KB
Binary file not shown.
-28.2 KB
Binary file not shown.

docs/Codex_2025DEC07.md

Lines changed: 0 additions & 169 deletions
This file was deleted.

docs/petersen_brd_right_cosets.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Before BRD computation, `verify_basic_facts()` asserts:
6363

6464
## Output
6565
The script prints:
66-
- graph size data,
66+
- graph size summary,
6767
- automorphism-group size,
6868
- right-coset count,
6969
- BRD over right-coset representatives,
@@ -91,3 +91,4 @@ From repository root:
9191
```bash
9292
.venv/Scripts/python.exe experiments/petersen_brd_right_cosets.py
9393
```
94+

examples/ab_mlp_demo.py

Lines changed: 22 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,36 @@
1-
"""Run a tiny A/B experiment comparing boundary penalties."""
1+
"""Run a tiny A/B experiment comparing horn-filler uniqueness."""
22

3-
import math
4-
from typing import Tuple
5-
6-
try: # pragma: no cover - optional dependency
7-
import torch
8-
from torch import nn
9-
from torch.utils.data import DataLoader, TensorDataset
10-
except ModuleNotFoundError: # pragma: no cover - friendly exit when torch missing
11-
print("PyTorch is required to run the boundary penalty demo. Please install torch.")
12-
raise SystemExit(0)
13-
14-
from simplicial_tensors.nn import BoundaryConfig, train_with_boundary
15-
16-
17-
def make_synthetic_dataset(n: int = 1024, noise: float = 0.1) -> Tuple[TensorDataset, TensorDataset]:
18-
torch.manual_seed(0)
19-
x = torch.randn(n, 2)
20-
y = torch.sign(x[:, 0] * x[:, 1]).unsqueeze(-1)
21-
y[y == 0] = 1
22-
y = (y > 0).float()
23-
24-
x += noise * torch.randn_like(x)
25-
split = n // 5
26-
val_x, val_y = x[:split], y[:split]
27-
train_x, train_y = x[split:], y[split:]
28-
train_ds = TensorDataset(train_x, train_y)
29-
val_ds = TensorDataset(val_x, val_y)
30-
return train_ds, val_ds
3+
from __future__ import annotations
314

5+
from typing import Tuple
326

33-
def make_model(seed: int = 0) -> nn.Module:
34-
torch.manual_seed(seed)
35-
return nn.Sequential(
36-
nn.Linear(2, 32),
37-
nn.ReLU(),
38-
nn.Linear(32, 32),
39-
nn.ReLU(),
40-
nn.Linear(32, 1),
41-
)
7+
import numpy as np
428

9+
from simplicial_tensors.tensor_ops import (
10+
filler,
11+
horn,
12+
n_hypergroupoid_conjecture,
13+
random_tensor,
14+
)
4315

44-
def run_job(mode: str, coboundary: str = "zero", lambda1: float = 1e-3, epochs: int = 10) -> None:
45-
device = "cuda" if torch.cuda.is_available() else "cpu"
46-
train_ds, val_ds = make_synthetic_dataset()
47-
train_loader = DataLoader(train_ds, batch_size=64, shuffle=True)
48-
val_loader = DataLoader(val_ds, batch_size=64)
4916

50-
model = make_model(seed=42)
51-
optimizer = torch.optim.Adam(model.parameters(), lr=5e-3)
52-
criterion = nn.BCEWithLogitsLoss()
17+
def run_case(shape: Tuple[int, ...], missing_face: int, seed: int) -> None:
18+
tensor = random_tensor(shape, low=-5, high=6, seed=seed)
19+
horn_faces = horn(tensor, missing_face)
20+
reconstructed = filler(horn_faces, missing_face)
21+
unique = np.array_equal(tensor, reconstructed)
22+
predicted = n_hypergroupoid_conjecture(shape)
5323

54-
cfg = BoundaryConfig(mode=mode, coboundary=coboundary, lambda1=lambda1)
55-
history = train_with_boundary(
56-
model,
57-
train_loader,
58-
val_loader,
59-
optimizer,
60-
criterion,
61-
device,
62-
epochs,
63-
cfg,
24+
print(
25+
f"shape={shape} omitted_face={missing_face} predicted_unique={predicted} "
26+
f"observed_unique={unique}"
6427
)
6528

66-
final_loss = history["val_loss"][-1]
67-
final_boundary = history["val_boundary"][-1]
68-
print(f"Mode={mode!r} coboundary={coboundary!r}: val_loss={final_loss:.4f} boundary={final_boundary:.4f}")
69-
7029

7130
def main() -> None:
72-
print("=== Boundary penalty A/B demo ===")
73-
run_job(mode="incidence", lambda1=5e-4, epochs=8)
74-
run_job(mode="principal", coboundary="zero", lambda1=5e-4, epochs=8)
31+
print("=== Horn filler A/B demo ===")
32+
run_case(shape=(3, 3), missing_face=1, seed=123)
33+
run_case(shape=(5, 5), missing_face=1, seed=456)
7534

7635

7736
if __name__ == "__main__":

0 commit comments

Comments
 (0)