Threshold Logic Circuits
Collection
Boolean gates, voting functions, modular arithmetic, and adders as threshold networks.
β’
248 items
β’
Updated
β’
1
4:1 multiplexer as threshold circuit. Selects one of four data inputs based on 2-bit select signal.
d0 βββ
d1 βββΌβββΊ MUX4 βββΊ out
d2 βββ€ β²
d3 βββ β
s1 s0
| s1 | s0 | out |
|---|---|---|
| 0 | 0 | d0 |
| 0 | 1 | d1 |
| 1 | 0 | d2 |
| 1 | 1 | d3 |
| Layer | Neurons | Function |
|---|---|---|
| 1 | 4 | Select gates (one per input) |
| 2 | 1 | OR (combine selections) |
Total: 5 neurons, 39 parameters, 2 layers
Each select gate fires only when:
from safetensors.torch import load_file
import torch
w = load_file('model.safetensors')
def mux4(d0, d1, d2, d3, s1, s0):
inp = torch.tensor([float(d0), float(d1), float(d2), float(d3),
float(s1), float(s0)])
l1 = (inp @ w['layer1.weight'].T + w['layer1.bias'] >= 0).float()
out = (l1 @ w['layer2.weight'].T + w['layer2.bias'] >= 0).float()
return int(out.item())
threshold-mux4/
βββ model.safetensors
βββ create_safetensors.py
βββ config.json
βββ README.md
MIT