Threshold Logic Circuits
Collection
Boolean gates, voting functions, modular arithmetic, and adders as threshold networks.
β’
248 items
β’
Updated
β’
1
4-input NAND gate. Outputs 0 only when all inputs are 1.
x1 x2 x3 x4
β β β β
βββββ΄ββββ΄ββββ
β
βΌ
ββββββββββββ
βw:-1,-1,-1,-1β
β b: 3 β
ββββββββββββ
β
βΌ
NAND4(x1,x2,x3,x4)
| Weights | [-1, -1, -1, -1] |
| Bias | 3 |
| Magnitude | 7 |
Exhaustive enumeration of 7,183 configurations confirms magnitude 7 is optimal. 1 valid configuration exists.
| Magnitude | Valid Configs |
|---|---|
| 0-6 | 0 |
| 7 | 1 |
from safetensors.torch import load_file
import torch
w = load_file('model.safetensors')
def nand4(x1, x2, x3, x4):
inputs = torch.tensor([float(x1), float(x2), float(x3), float(x4)])
return int((inputs * w['weight']).sum() + w['bias'] >= 0)
MIT