Threshold Logic Circuits
Collection
Boolean gates, voting functions, modular arithmetic, and adders as threshold networks.
•
269 items
•
Updated
•
1
1-bit greater-than-or-equal comparator. Outputs 1 when a >= b.
gte(a, b) = 1 if a >= b, else 0
Equivalent to: a OR NOT(b) (reverse implication)
| a | b | a >= b |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
Single neuron: weights [1, -1], bias 0
Fires when: a - b >= 0, i.e., a >= b
| 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 gte(a, b):
inp = torch.tensor([float(a), float(b)])
return int((inp @ w['neuron.weight'].T + w['neuron.bias'] >= 0).item())
print(gte(1, 0)) # 1
print(gte(0, 1)) # 0
MIT