threshold-mod6

Computes Hamming weight mod 6 directly on inputs. Single-layer circuit.

Circuit

  xβ‚€ x₁ xβ‚‚ x₃ xβ‚„ xβ‚… x₆ x₇
   β”‚  β”‚  β”‚  β”‚  β”‚  β”‚  β”‚  β”‚
   β”‚  β”‚  β”‚  β”‚  β”‚  β”‚  β”‚  β”‚
   w: 1  1  1  1  1 -5  1  1
   β””β”€β”€β”΄β”€β”€β”΄β”€β”€β”΄β”€β”€β”Όβ”€β”€β”΄β”€β”€β”΄β”€β”€β”΄β”€β”€β”˜
               β–Ό
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚ b:  0   β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚
               β–Ό
           HW mod 6

Algebraic Insight

For 8 inputs and mod 6, position 6 gets weight 1-6 = -5:

  • Positions 1-5: weight +1
  • Position 6: weight -5 (reset: 1+1+1+1+1-5 = 0)
  • Positions 7-8: weight +1
HW=0: sum=0 β†’ 0 mod 6
HW=1: sum=1 β†’ 1 mod 6
...
HW=5: sum=5 β†’ 5 mod 6
HW=6: sum=0 β†’ 0 mod 6  (reset)
HW=7: sum=1 β†’ 1 mod 6
HW=8: sum=2 β†’ 2 mod 6

Parameters

Weights [1, 1, 1, 1, 1, -5, 1, 1]
Bias 0
Total 9 parameters

Usage

from safetensors.torch import load_file
import torch

w = load_file('model.safetensors')

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

Files

threshold-mod6/
β”œβ”€β”€ 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-mod6