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
10
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Collection including phanerozoic/threshold-atmost4outof8