threshold-1outof6

At-least-one detector for 6 inputs. Equivalent to a 6-input OR gate. The loosest threshold in the k-out-of-6 family.

Circuit

  x0  x1  x2  x3  x4  x5
   β”‚   β”‚   β”‚   β”‚   β”‚   β”‚
   β””β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”Όβ”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”˜
               β–Ό
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚ w: all 1β”‚
          β”‚ b:  -1  β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚
               β–Ό
            HW >= 1

Function

1outof6(x0, x1, x2, x3, x4, x5) = 1 if (x0 + x1 + x2 + x3 + x4 + x5) >= 1

Returns 1 when at least one input is high (Hamming weight >= 1).

Truth Table (selected)

Inputs HW Output
000000 0 0
000001 1 1
000010 1 1
010101 3 1
111111 6 1

Only the all-zeros input produces 0.

Mechanism

With uniform weights of 1 and bias -1, the neuron fires when at least one input is active:

  • Sum = (number of 1s) - 1
  • Fires when sum >= 0, i.e., when Hamming weight >= 1

k-out-of-6 Family

Circuit Bias Fires when
1-out-of-6 -1 HW >= 1 (this)
2-out-of-6 -2 HW >= 2
3-out-of-6 -3 HW >= 3
4-out-of-6 -4 HW >= 4
5-out-of-6 -5 HW >= 5
6-out-of-6 -6 HW = 6

All share weights [1,1,1,1,1,1]. Only the bias differs.

Parameters

Weights [1, 1, 1, 1, 1, 1]
Bias -1
Inputs 6
Outputs 1
Neurons 1
Layers 1
Parameters 7
Magnitude 7

Usage

from safetensors.torch import load_file
import torch

w = load_file('model.safetensors')

def at_least_1_of_6(bits):
    inputs = torch.tensor([float(b) for b in bits])
    return int((inputs @ w['neuron.weight'].T + w['neuron.bias'] >= 0).item())

# Examples
print(at_least_1_of_6([0, 0, 0, 0, 0, 0]))  # 0
print(at_least_1_of_6([0, 0, 0, 0, 0, 1]))  # 1
print(at_least_1_of_6([1, 0, 1, 0, 1, 0]))  # 1

Applications

  • Any-input-active detection
  • Interrupt pending flags
  • Error aggregation
  • Valid signal generation

Files

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

License

MIT

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

Collection including phanerozoic/threshold-1outof6