threshold-demux

1:2 demultiplexer. Routes a data signal to one of two outputs based on a select signal.

Circuit

      d       s
      β”‚       β”‚
      β”œβ”€β”€β”€β”€β”€β”€β”€β”€
      β”‚       β”‚
      β–Ό       β–Ό
  β”Œβ”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”
  │d AND¬s│ │d AND s│
  β”‚w=[1,-1]β”‚ β”‚w=[1,1]β”‚
  β”‚b=-1   β”‚ β”‚b=-2   β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”˜
      β”‚         β”‚
      β–Ό         β–Ό
     y0        y1

Function

  • y0 = d when s=0, else 0
  • y1 = d when s=1, else 0

The select signal routes the data to exactly one output.

Truth Table

d s y0 y1
0 0 0 0
0 1 0 0
1 0 1 0
1 1 0 1

Architecture

Output Function Weights Bias
y0 d AND NOT(s) [1, -1] -1
y1 d AND s [1, 1] -2

Total: 2 neurons, 6 parameters, 1 layer

Single-layer circuit - both outputs are linearly separable.

Optimality

Exhaustive enumeration of all 19,825 weight configurations at magnitudes 0-7 confirms this circuit is already at minimum magnitude (7). There is exactly one valid configuration at magnitude 7, and no valid configurations exist below it.

Usage

from safetensors.torch import load_file
import torch

w = load_file('model.safetensors')

def demux(d, s):
    inp = torch.tensor([float(d), float(s)])
    y0 = int((inp @ w['y0.weight'].T + w['y0.bias'] >= 0).item())
    y1 = int((inp @ w['y1.weight'].T + w['y1.bias'] >= 0).item())
    return y0, y1

print(demux(1, 0))  # (1, 0) - routes to y0
print(demux(1, 1))  # (0, 1) - routes to y1

Files

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

License

MIT

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

Collection including phanerozoic/threshold-demux