threshold-xor3-mag10

3-input XOR gate at optimal magnitude 10.

Discovery

Exhaustive search over 387,328,512 configurations proved magnitude 10 is optimal for XOR3. This flat 2-layer architecture beats the cascade approach (magnitude 14) by 29%.

Architecture Neurons Params Magnitude
Cascade (2Γ—XOR) 6 18 14
Flat 3-hidden 4 16 10

Architecture

a ──┐
b ──┼──► [h1] ──┐
c β”€β”€β”˜    [h2] ──┼──► [out] ──► XOR3(a,b,c)
         [h3] β”€β”€β”˜

Single hidden layer with 3 neurons, all biases = 0.

Solutions

18 solutions exist at magnitude 10, related by input permutation and neuron reordering symmetry.

Solution h1 weights h2 weights h3 weights out weights
1 [-1,0,0] [-1,-1,1] [-1,1,-1] [1,-1,-1]
2 [-1,0,0] [-1,1,-1] [-1,-1,1] [1,-1,-1]
3 [0,-1,0] [-1,-1,1] [1,-1,-1] [1,-1,-1]
4 [0,-1,0] [1,-1,-1] [-1,-1,1] [1,-1,-1]
5 [0,0,-1] [-1,1,-1] [1,-1,-1] [1,-1,-1]
6 [0,0,-1] [1,-1,-1] [-1,1,-1] [1,-1,-1]
7 [-1,-1,1] [-1,0,0] [-1,1,-1] [-1,1,-1]
8 [-1,-1,1] [0,-1,0] [1,-1,-1] [-1,1,-1]
9 [-1,1,-1] [-1,0,0] [-1,-1,1] [-1,1,-1]
10 [-1,1,-1] [0,0,-1] [1,-1,-1] [-1,1,-1]
11 [1,-1,-1] [0,-1,0] [-1,-1,1] [-1,1,-1]
12 [1,-1,-1] [0,0,-1] [-1,1,-1] [-1,1,-1]
13 [-1,-1,1] [-1,1,-1] [-1,0,0] [-1,-1,1]
14 [-1,-1,1] [1,-1,-1] [0,-1,0] [-1,-1,1]
15 [-1,1,-1] [-1,-1,1] [-1,0,0] [-1,-1,1]
16 [-1,1,-1] [1,-1,-1] [0,0,-1] [-1,-1,1]
17 [1,-1,-1] [-1,-1,1] [0,-1,0] [-1,-1,1]
18 [1,-1,-1] [-1,1,-1] [0,0,-1] [-1,-1,1]

Hidden Neuron Types

Six unique neuron types appear across solutions:

Type Weights Function
Sel-a [-1,0,0] fires when a=0
Sel-b [0,-1,0] fires when b=0
Sel-c [0,0,-1] fires when c=0
XOR-ab [-1,-1,1] fires when c>(a+b)
XOR-ac [-1,1,-1] fires when b>(a+c)
XOR-bc [1,-1,-1] fires when a>(b+c)

Files

threshold-xor3-mag10/
β”œβ”€β”€ model.safetensors      (default = solution1)
β”œβ”€β”€ solution1.safetensors
β”œβ”€β”€ solution2.safetensors
β”œβ”€β”€ ...
β”œβ”€β”€ solution18.safetensors
β”œβ”€β”€ model.py
β”œβ”€β”€ config.json
└── README.md

Usage

from safetensors.torch import load_file
import torch

w = load_file('model.safetensors')  # or solution1-18

def xor3(a, b, c):
    inp = torch.tensor([float(a), float(b), float(c)])
    h1 = int((inp * w['h1.weight']).sum() + w['h1.bias'] >= 0)
    h2 = int((inp * w['h2.weight']).sum() + w['h2.bias'] >= 0)
    h3 = int((inp * w['h3.weight']).sum() + w['h3.bias'] >= 0)
    hidden = torch.tensor([float(h1), float(h2), float(h3)])
    return int((hidden * w['out.weight']).sum() + w['out.bias'] >= 0)

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-xor3-mag10