Threshold Logic Circuits
Collection
Boolean gates, voting functions, modular arithmetic, and adders as threshold networks.
•
269 items
•
Updated
•
1
1-bit less-than-or-equal comparator. Outputs 1 when a <= b.
lte(a, b) = 1 if a <= b, else 0
Equivalent to: NOT(a) OR b (implication)
| a | b | a <= b |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Single neuron: weights [-1, 1], bias 0
Fires when: -a + b >= 0, i.e., b >= a
| Inputs | 2 |
| Outputs | 1 |
| Neurons | 1 |
| Layers | 1 |
| Parameters | 3 |
| Magnitude | 2 |
from safetensors.torch import load_file
import torch
w = load_file('model.safetensors')
def lte(a, b):
inp = torch.tensor([float(a), float(b)])
return int((inp @ w['neuron.weight'].T + w['neuron.bias'] >= 0).item())
print(lte(0, 1)) # 1
print(lte(1, 0)) # 0
MIT