Threshold Logic Circuits
Collection
Boolean gates, voting functions, modular arithmetic, and adders as threshold networks. • 269 items • Updated • 1
Sparse activation detector. Fires when few inputs are active (3 or fewer of 8).
x₀ x₁ x₂ x₃ x₄ x₅ x₆ x₇
│ │ │ │ │ │ │ │
└──┴──┴──┴──┼──┴──┴──┴──┘
▼
┌──────────┐
│ w: all -1│
│ b: +3 │
└──────────┘
│
▼
HW ≤ 3?
Negative weights flip the logic. Each active input subtracts from the sum:
| HW | Sum | Output |
|---|---|---|
| 0 | +3 | 1 |
| 1 | +2 | 1 |
| 2 | +1 | 1 |
| 3 | 0 | 1 |
| 4 | -1 | 0 |
| ... | ... | 0 |
| Circuit | Weights | Bias | Fires when |
|---|---|---|---|
| Majority | all +1 | -5 | HW ≥ 5 |
| Minority | all -1 | +3 | HW ≤ 3 |
These aren't complements. At HW=4, both are silent. This is the "tie zone" - neither majority nor minority.
| Weights | [-1, -1, -1, -1, -1, -1, -1, -1] |
| Bias | +3 |
| Total | 9 parameters |
from safetensors.torch import load_file
import torch
w = load_file('model.safetensors')
def minority(bits):
inputs = torch.tensor([float(b) for b in bits])
return int((inputs * w['weight']).sum() + w['bias'] >= 0)
threshold-minority/
├── model.safetensors
├── model.py
├── config.json
└── README.md
MIT