Threshold Logic Circuits
Collection
Boolean gates, voting functions, modular arithmetic, and adders as threshold networks. • 269 items • Updated • 1
Supermajority detector. Fires when 6 or more of 8 inputs are set (75%+).
x₀ x₁ x₂ x₃ x₄ x₅ x₆ x₇
│ │ │ │ │ │ │ │
└──┴──┴──┴──┼──┴──┴──┴──┘
▼
┌─────────┐
│ w: all 1│
│ b: -6 │
└─────────┘
│
▼
HW ≥ 6
A 75% threshold. Tolerates up to 2 missing inputs.
| Circuit | Bias | Fires when |
|---|---|---|
| ... | ... | ... |
| 5-out-of-8 | -5 | HW ≥ 5 |
| 6-out-of-8 | -6 | HW ≥ 6 (this) |
| 7-out-of-8 | -7 | HW ≥ 7 |
| 8-out-of-8 | -8 | HW = 8 |
| Weights | [1, 1, 1, 1, 1, 1, 1, 1] |
| Bias | -6 |
| Total | 9 parameters |
from safetensors.torch import load_file
import torch
w = load_file('model.safetensors')
def at_least_6(bits):
inputs = torch.tensor([float(b) for b in bits])
return int((inputs * w['weight']).sum() + w['bias'] >= 0)
threshold-6outof8/
├── model.safetensors
├── model.py
├── config.json
└── README.md
MIT
Totally Free + Zero Barriers + No Login Required