Downloads · 30 days
3
7% of all-time downloads
phanerozoic/threshold-xor3-mag10
threshold-xor3-mag10 is a machine learning model from phanerozoic. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
3-input XOR gate at optimal magnitude 10.
Downloads · 30 days
3
7% of all-time downloads
All-time downloads
41
Public
Parameters
16
10.2 KB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors10.8 KB · 53%
From the Hugging Face model README
3-input XOR gate at optimal magnitude 10.
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 |
a ──┐
b ──┼──► [h1] ──┐
c ──┘ [h2] ──┼──► [out] ──► XOR3(a,b,c)
[h3] ──┘
Single hidden layer with 3 neurons, all biases = 0.
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] |
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) |
threshold-xor3-mag10/
├── model.safetensors (default = solution1)
├── solution1.safetensors
├── solution2.safetensors
├── ...
├── solution18.safetensors
├── model.py
├── config.json
└── README.md
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)
MIT