Views
No views yet
x₀ x₁ x₂ x₃ x₄ x₅ x₆ x₇
│ │ │ │ │ │ │ │
└──┴──┴──┴──┼──┴──┴──┴──┘
▼
┌─────────────┐
│ Thermometer │ Layer 1: 9 neurons
│ Encoding │
└─────────────┘
│
▼
┌─────────────┐
│ MOD-5 │ Layer 2: 4 neurons
│ Detection │ Pattern (1,1,1,1,-4)
└─────────────┘
│
▼
┌─────────────┐
│ Classify │ Output: 5 classes
└─────────────┘
│
▼
{0, 1, 2, 3, 4}(1, 1, 1, 1, -4) causes cumulative sums to cycle mod 5:HW=0: sum=0 → 0 mod 5
HW=1: sum=1 → 1 mod 5
HW=2: sum=2 → 2 mod 5
HW=3: sum=3 → 3 mod 5
HW=4: sum=4 → 4 mod 5
HW=5: sum=0 → 0 mod 5 (reset: 1+1+1+1-4=0)
HW=6: sum=1 → 1 mod 5
HW=7: sum=2 → 2 mod 5
HW=8: sum=3 → 3 mod 5| Layer | Neurons | Function |
|---|---|---|
| Input | 8 | Binary bits |
| Hidden 1 | 9 | Thermometer encoding |
| Hidden 2 | 4 | MOD-5 detection |
| Output | 5 | One-hot classification |
| Class | HW values | Count/256 |
|---|---|---|
| 0 | 0, 5 | 57 |
| 1 | 1, 6 | 36 |
| 2 | 2, 7 | 36 |
| 3 | 3, 8 | 57 |
| 4 | 4 | 70 |
1from safetensors.torch import load_file
2import torch
3
4w = load_file('model.safetensors')
5
6def forward(x):
7 x = x.float()
8 x = (x @ w['layer1.weight'].T + w['layer1.bias'] >= 0).float()
9 x = (x @ w['layer2.weight'].T + w['layer2.bias'] >= 0).float()
10 out = x @ w['output.weight'].T + w['output.bias']
11 return out.argmax(dim=-1)threshold-mod5/
├── model.safetensors
├── model.py
├── config.json
└── README.md