Threshold Logic Circuits
Collection
Boolean gates, voting functions, modular arithmetic, and adders as threshold networks.
β’
248 items
β’
Updated
β’
1
At-least-two detector for 8 inputs. Fires when 2 or more bits are set.
xβ xβ xβ xβ xβ xβ
xβ xβ
β β β β β β β β
ββββ΄βββ΄βββ΄βββΌβββ΄βββ΄βββ΄βββ
βΌ
βββββββββββ
β w: all 1β
β b: -2 β
βββββββββββ
β
βΌ
HW β₯ 2
A single active input isn't enough. Needs corroboration from at least one other.
| Circuit | Bias | Fires when |
|---|---|---|
| 1-out-of-8 | -1 | HW β₯ 1 |
| 2-out-of-8 | -2 | HW β₯ 2 (this) |
| 3-out-of-8 | -3 | HW β₯ 3 |
| ... | ... | ... |
All share weights [1,1,1,1,1,1,1,1]. Only the bias differs.
| Weights | [1, 1, 1, 1, 1, 1, 1, 1] |
| Bias | -2 |
| Total | 9 parameters |
from safetensors.torch import load_file
import torch
w = load_file('model.safetensors')
def at_least_2(bits):
inputs = torch.tensor([float(b) for b in bits])
return int((inputs * w['weight']).sum() + w['bias'] >= 0)
threshold-2outof8/
βββ model.safetensors
βββ model.py
βββ config.json
βββ README.md
MIT