threshold-nand4

4-input NAND gate. Outputs 0 only when all inputs are 1.

Circuit

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

Parameters

Weights [-1, -1, -1, -1]
Bias 3
Magnitude 7

Optimality

Exhaustive enumeration of 7,183 configurations confirms magnitude 7 is optimal. 1 valid configuration exists.

Magnitude Valid Configs
0-6 0
7 1

Usage

from safetensors.torch import load_file
import torch

w = load_file('model.safetensors')

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

License

MIT

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

Collection including phanerozoic/threshold-nand4