threshold-or4

A 1-of-4 threshold gate. Any single active input is enough to fire.

Circuit

  x1  x2  x3  x4
   β”‚   β”‚   β”‚   β”‚
   β””β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”˜
         β”‚
         β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚w: 1,1,1,1β”‚
    β”‚ b: -1   β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
   OR4(x1,x2,x3,x4)

Mechanism

Same weights as AND4, but bias -1 instead of -4. A single vote suffices:

x1 x2 x3 x4 sum output
0 0 0 0 -1 0
0 0 0 1 0 1
... ... ... ... ... 1
1 1 1 1 3 1

Parameters

Weights [1, 1, 1, 1]
Bias -1
Magnitude 5
Total 5 parameters

Optimality

Exhaustive enumeration of all 1,683 weight configurations at magnitudes 0-5 confirms this circuit is at minimum magnitude (5). There is exactly 1 valid configuration at magnitude 5, and no valid configurations exist below it.

Magnitude Valid Configs
0-4 0
5 1

Properties

  • Linearly separable (single neuron suffices)
  • De Morgan dual: OR4(x1,x2,x3,x4) = NOT(AND4(NOT(x1), NOT(x2), NOT(x3), NOT(x4)))

Usage

from safetensors.torch import load_file
import torch

w = load_file('model.safetensors')

def or4_gate(x1, x2, x3, x4):
    inputs = torch.tensor([float(x1), float(x2), float(x3), float(x4)])
    return int((inputs * w['weight']).sum() + w['bias'] >= 0)

assert or4_gate(0, 0, 0, 0) == 0
assert or4_gate(0, 0, 0, 1) == 1
assert or4_gate(1, 1, 1, 1) == 1

Files

threshold-or4/
β”œβ”€β”€ model.safetensors
β”œβ”€β”€ model.py
β”œβ”€β”€ config.json
β”œβ”€β”€ create_safetensors.py
└── README.md

License

MIT

Downloads last month
12
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Collection including phanerozoic/threshold-or4