metadata
license: mit
tags:
- pytorch
- safetensors
- threshold-logic
- neuromorphic
threshold-or
A 1-of-2 threshold gate. One active input is enough to fire.
Circuit
x y
β β
βββ¬ββ
βΌ
βββββββββ
β w: 1,1β
β b: -1 β
βββββββββ
β
βΌ
OR(x,y)
Mechanism
Same weights as AND, but bias -1 instead of -2. The lower bar means a single vote suffices:
| x | y | sum | output |
|---|---|---|---|
| 0 | 0 | -1 | 0 |
| 0 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 |
AND and OR are the same circuit with different thresholds. This is the essence of threshold logic: the bias determines how many inputs must agree.
Parameters
| Weights | [1, 1] |
| Bias | -1 |
| Total | 3 parameters |
Optimality
Exhaustive enumeration of all 25 weight configurations at magnitudes 0-3 confirms this circuit is already at minimum magnitude (3). There is exactly one valid configuration at magnitude 3, and no valid configurations exist below it.
Properties
- Linearly separable
- De Morgan dual: OR(x,y) = NOT(AND(NOT(x), NOT(y)))
- Generalizes to n-input OR with weights all 1, bias -1
Usage
from safetensors.torch import load_file
import torch
w = load_file('model.safetensors')
def or_gate(x, y):
inputs = torch.tensor([float(x), float(y)])
return int((inputs * w['weight']).sum() + w['bias'] >= 0)
Files
threshold-or/
βββ model.safetensors
βββ model.py
βββ config.json
βββ README.md
License
MIT