threshold-atmost4outof8

At-most-4-out-of-8 detector. Fires when half or fewer inputs are active. The non-majority detector.

Circuit

  x₀ x₁ x₂ x₃ x₄ x₅ x₆ x₇
   │  │  │  │  │  │  │  │
   └──┴──┴──┴──┼──┴──┴──┴──┘
               ▼
          ┌─────────┐
          │ w: -1×8 │
          │ b:  +4  │
          └─────────┘
               │
               ▼
           HW ≤ 4?

The Majority Complement

This is NOT(Majority):

HW Majority (≥5) AtMost4 (≤4)
0-4 0 1
5-8 1 0

Exactly one fires for any input. They partition the input space.

Includes Ties

HW AtMost3 AtMost4 AtMost5
3 1 1 1
4 0 1 1
5 0 0 1

AtMost4 is the first in the family to include the tie case (HW = 4).

Coverage

Fires on more than half of all inputs:

HW C(8,k) AtMost4?
0 1 Yes
1 8 Yes
2 28 Yes
3 56 Yes
4 70 Yes
5-8 93 No

Total: 1 + 8 + 28 + 56 + 70 = 163 of 256 inputs (63.7%).

Dual of AtLeast4

Circuit Condition Fires on
AtLeast4 HW ≥ 4 163 inputs
AtMost4 HW ≤ 4 163 inputs

Both fire on 163 inputs, but different sets. Their intersection is exactly HW = 4 (70 inputs).

Parameters

Component Value
Weights all -1
Bias +4
Total 9 parameters

Usage

from safetensors.torch import load_file
import torch

w = load_file('model.safetensors')

def atmost4(bits):
    inp = torch.tensor([float(b) for b in bits])
    return int((inp * w['weight']).sum() + w['bias'] >= 0)

# Tie (4 active): included
print(atmost4([1,1,1,1,0,0,0,0]))  # 1

# Majority (5 active): excluded
print(atmost4([1,1,1,1,1,0,0,0]))  # 0

Files

threshold-atmost4outof8/
├── model.safetensors
├── model.py
├── config.json
└── README.md

License

MIT

Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Collection including phanerozoic/threshold-atmost4outof8

Free AI Image Generator No sign-up. Instant results. Open Now